Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(create-vite): add @node/types to typescript templates #18642

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smeng9
Copy link
Contributor

@smeng9 smeng9 commented Nov 11, 2024

Closes #18600

@ArnaudBarre
Copy link
Member

If we go in that direction, I think we should also add types to node and app tsconfigs so that node types don't pollute default client code.
It also avoid the need for a vite-env.d.ts which IMO it's cleaner and what I do in my projects

@bluwy
Copy link
Member

bluwy commented Nov 12, 2024

Setting that has a different semantic to a separate file: https://www.typescriptlang.org/tsconfig/#types, so I'm not really sure if we should change that

@ArnaudBarre
Copy link
Member

Yeah I know it's different, but that the goal: you don't want to have process.env be ok for TS in the app files.

@smeng9
Copy link
Contributor Author

smeng9 commented Nov 12, 2024

you don't want to have process.env be ok for TS in the app files.

We do use a lot of process.env in our frontend code, particularly process.env.NODE_ENV == "development" to switch to a dev rest api url.

Vite also allows process.env in app files https://vite.dev/guide/env-and-mode#node-env-and-modes

@ArnaudBarre
Copy link
Member

While this is supported for compatibility with the ecosystem, Vite way of doing this is import.meta.DEV which avoid using a Node concept inside a code that will run in browser

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add @types/node as devDependency to all typescript templates
3 participants