Typescript reports 0 erros
PLkolek opened this issue · 5 comments
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, but npm 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
- Import and use checker in vite.config.ts with
typescript: true
- Introduce type error in
src/App.tsx
npm run dev
Expected behavior
Expected result: same error as when executing npm run build
.
src/App.tsx:21:41 - error TS2345: Argument of type '(count: number) => string' is not assignable to parameter of type 'SetStateAction<number>'.
Type '(count: number) => string' is not assignable to type '(prevState: number) => number'.
Type 'string' is not assignable to type 'number'.
21 <button onClick={() => setCount((count) => "123")}>
Actual result: no errors detected.
VITE v5.4.0 ready in 435 ms
➜ Local: http://localhost:5173/
➜ Network: use --host to expose
➜ press h + enter to show help
[TypeScript] Found 0 errors. Watching for file changes.
System Info
System:
OS: Linux 5.10 Ubuntu 20.04 LTS (Focal Fossa)
CPU: (8) x64 Intel(R) Core(TM) i5-10210U CPU @ 1.60GHz
Memory: 5.04 GB / 7.69 GB
Container: Yes
Shell: 5.0.16 - /bin/bash
Binaries:
Node: 20.13.1 - ~/.nvm/versions/node/v20.13.1/bin/node
npm: 10.5.2 - ~/.nvm/versions/node/v20.13.1/bin/npm
npmPackages:
vite-plugin-checker: ^0.7.2 => 0.7.2
Additional context
No response
Validations
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
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.