vite-plugin-checker
vite-plugin-checker copied to clipboard
Unwanted typescript errors when dev server is started
Describe the bug
Note that I am running vite under a monorepo setup, specifically using pnpm workspaces. I just bootstrapped the app with react-ts and vite-plugin-checker is the only plugin installed. I can see the following error
5:27:36 AM [vite] vite.config.ts changed, restarting server...
5:27:36 AM [vite] server restarted.
ERROR(TypeScript) Duplicate identifier 'Prepend'.
FILE /home/<USER>/project/node_modules/.pnpm/@[email protected]/node_modules/@types/eslint/helpers.d.ts:1:6
> 1 | type Prepend<Tuple extends any[], Addend> = ((_: Addend, ..._1: Tuple) => any) extends (..._: infer Result) => any
| ^^^^^^^
2 | ? Result
3 | : never;
4 |
ERROR(TypeScript) Duplicate identifier 'Prepend'.
FILE /home/<USER>/project/node_modules/.pnpm/@[email protected]/node_modules/@types/eslint/helpers.d.ts:1:6
> 1 | type Prepend<Tuple extends any[], Addend> = ((_: Addend, ..._1: Tuple) => any) extends (..._: infer Result) => any
| ^^^^^^^
2 | ? Result
3 | : never;
4 |
[TypeScript] Found 2 errors. Watching for file changes.
Screenshot:
This is my config file:
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import checker from 'vite-plugin-checker'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react(), checker({
typescript: {
root: '.', tsconfigPath: 'tsconfig.json'
}
})],
server: {
host: '0.0.0.0',
port: 3000,
}
})
Reproduction
- add new module under a pnpm monorepo (with eslint being a dependency in other workspace packages)
- start the dev server with the
vite-plugin-checker
plugin added
Expected behavior
The plugin should only typecheck source folder contents
System Info
System:
OS: Linux 5.4 Ubuntu 20.04.3 LTS (Focal Fossa)
CPU: (2) x64 DO-Regular
Memory: 482.94 MB / 3.84 GB
Container: Yes
Shell: 5.8 - /usr/bin/zsh
Binaries:
Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
Yarn: 1.22.17 - ~/.nvm/versions/node/v14.17.0/bin/yarn
npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
npmPackages:
vite-plugin-checker: ^0.4.4 => 0.4.4
Additional context
No response
Validations
- [X] Read the docs.
- [X] Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
any issues reported by running tsc --noEmit
?
I got a similar issue with [email protected]
and [email protected]
. Turns out it was because skipLibCheck
was set to true
in my project tsconfig.json
file.
@val1984 I think setting skipLibCheck
to true can eliminate this report. And could you run tsc --noEmit
in your project to verify is it the right report from tsc?
Sorry, I wasn't clear in my previous message but it definitely fixed the issue for me.
@smtrd3 Can you try this solution?
For anyone who encounters similar issues. You can run tsc --noEmit
or vue-tsc --noEmit
under your project. If the command reports the same issues, then there's nothing to do with vite-plugin-checker cause it just forwards the issues. If not, please leave a comment below.
I am having the same problem, in my case I am getting way more erros from node_modules libs:
My configuration is basic a copy from stackblitz example (react)
@guiphc add skipLibCheck: true
to tsconfig
@guiphc add
skipLibCheck: true
to tsconfig
this did not work, for some reason looks like the plugin did not respect my tsconfig.
@guiphc Provide a stackblitz link please
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If this is a bug report, please provide a minimal re-production repository or use path to reproduce. Thank you for your contributions.
I'm kind of experiencing this as well, though it's more of a bonus than a bug for me. If I run tsc --noEmit
the errors that are being reported by the plugin are indeed picked up by TypeScript, but these errors aren't reported in the IDE (VS Code). I know Vite doesn't really care, but they're of course not reported during the vite build
process as well, meaning I probably never would have caught these if I wasn't using the plugin. (❤️)
Is this a TypeScript bug, a VS Code bug or? Any hints on how I can make sure that these bugs are reported in the IDE as well?