You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The tsconfig file needs to be updated for new typescript project templates.
With the current configuration, the application may compile successfully but fail at runtime. To fix this, we only need to add "moduleDetection": "force" in the compilerOptions.
Add a new ts file inside the src folder (for example newfile.ts) with this content: const MY_CONST = 1
Print the value of the constant inside App.tsx : {MY_CONST},
At this point, you should be able to compile (with npx tsc --noEmit) or build the app ( npm run build ) without errors, but the app fails at runtime ( npm run dev ) in the preview.
To fix this, we only need to add "moduleDetection": "force" in the compilerOptions.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
Describe the bug
The
tsconfig
file needs to be updated for newtypescript
project templates.With the current configuration, the application may compile successfully but fail at runtime. To fix this, we only need to add
"moduleDetection": "force"
in thecompilerOptions
.More info here:microsoft/TypeScript#55785
Reproducible example here:https://stackblitz.com/edit/vitejs-vite-srbrdd
Reproduction
https://stackblitz.com/edit/vitejs-vite-srbrdd?file=tsconfig.json
Steps to reproduce
ts
file inside thesrc
folder (for examplenewfile.ts
) with this content:const MY_CONST = 1
App.tsx
:{MY_CONST}
,At this point, you should be able to compile (with
npx tsc --noEmit
) or build the app (npm run build
) without errors, but the app fails at runtime (npm run dev
) in the preview.To fix this, we only need to add
"moduleDetection": "force"
in thecompilerOptions
.System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: