Open PLkolek opened 3 months ago
Ah I see now. The project generated by npm create vite@latest my-react-app -- --template react-ts
uses references, and AFAIU this requires buildMode: true
. As I haven't worked with TS for a longer while I missed the whole references thing, and did not know what --build
flag means ("why would I need to build anything if I am just running a checker?!"). Maybe the docs could be more explicit when this flag is needed, or that some Vite templates need this "advanced" option?
Ah I see now. The project generated by
npm create vite@latest my-react-app -- --template react-ts
uses references, and AFAIU this requiresbuildMode: true
. As I haven't worked with TS for a longer while I missed the whole references thing, and did not know what--build
flag means ("why would I need to build anything if I am just running a checker?!"). Maybe the docs could be more explicit when this flag is needed, or that some Vite templates need this "advanced" option?
I am still confused, I also use react-ts template, where should I set the buildMode: true
or add the --build
flag? The vite-plugin-checker doesn't have buildMode
option but enableBuild
. I have already set enableBuild: true
but it still show 0 errors when in the development mode.
Ah I see now. The project generated by
npm create vite@latest my-react-app -- --template react-ts
uses references, and AFAIU this requiresbuildMode: true
. As I haven't worked with TS for a longer while I missed the whole references thing, and did not know what--build
flag means ("why would I need to build anything if I am just running a checker?!"). Maybe the docs could be more explicit when this flag is needed, or that some Vite templates need this "advanced" option?I am still confused, I also use react-ts template, where should I set the
buildMode: true
or add the--build
flag? The vite-plugin-checker doesn't havebuildMode
option butenableBuild
. I have already setenableBuild: true
but it still show 0 errors when in the development mode.
After adding buildMode: true
, I fixed the issue.
Solution:
vite.config.ts file
plugins: [
checker({
typescript: { buildMode: true },
}),
]
If you're starting a new Vite project, the default tsconfig.json
doesn't seem to work. Updating the config to point to tsconfig.app.json
seems to fix the problem for me.
export default defineConfig({
plugins: [
react(),
checker({
typescript: {
tsconfigPath: './tsconfig.app.json'
},
})
],
})
Describe the bug
After bootstrapping a Vite react-ts project and following vite-plugin-checker's "Getting Started" to set up Typescript checker, the checker seems to execute Typescript, but for some reason it doesn't detect any errors. I.e. running
npm run build
fails due to type errors, butnpm run dev
outputs [TypeScript] Found 0 errors. Watching for file changes.I using WSL on Windows - maybe this is what matters?
Reproduction
npm create vite@latest my-react-app -- --template react-ts
cd my-react-app
npm i vite-plugin-checker -D
typescript: true
src/App.tsx
npm run dev
Expected behavior
Expected result: same error as when executing
npm run build
.Actual result: no errors detected.
System Info
Additional context
No response
Validations