question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unwanted typescript errors when dev server is started

See original GitHub issue

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/@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: Screenshot 2022-03-31 at 11 15 59 AM

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:closed
  • Created a year ago
  • Comments:11 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
val1984commented, Apr 6, 2022

Sorry, I wasn’t clear in my previous message but it definitely fixed the issue for me.

@smtrd3 Can you try this solution?

0reactions
TurtIeSockscommented, Jul 14, 2022

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?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found