Unwanted typescript errors when dev server is started
See original GitHub issueDescribe 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/@types+eslint@7.29.0/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/@types+eslint@8.4.1/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
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
Issue Analytics
- State:
- Created a year ago
- Comments:11 (5 by maintainers)
Top Results From Across the Web
Not safe typescript compilation when webpack-dev-server ...
But as soon as I install ;webpack-dev-server' npm package, compiler stops seeing this problem and completes the compilation with no errors.
Read more >TypeScript errors and how to fix them
A list of common TypeScript errors and how to fix them.
Read more >Unexpected [ts] errors in JavaScript files · Issue #54261 - GitHub
In VS Code, run the TypeScript: Open TS Server log command; This should open a folder with a tsserver.log file in it. Please...
Read more >Improving TypeScript error handling with exhaustive type ...
Discover an improved method for handling errors in TypeScript that solves problems that arise from returning null and throwing try...catch.
Read more >Announcing TypeScript 4.6 - Microsoft Developer Blogs
TypeScript now shows JavaScript syntax and binding errors in your file, such as using incorrect modifiers, duplicate declarations, and more.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sorry, I wasn’t clear in my previous message but it definitely fixed the issue for me.
@smtrd3 Can you try this solution?
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 thevite 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?