Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add ref() and unref() to chokidar.d.ts for typescript build to work. #15706

Merged
merged 3 commits into from
Jan 29, 2024
Merged

Conversation

saerich
Copy link
Contributor

@saerich saerich commented Jan 24, 2024

Description

When attempting to build a vite project after updating from 5.0.8 to 5.0.12, received following error:
ERROR(TypeScript) Class 'import("D:/Projects/PROJECT/node_modules/vite/dist/node/index").FSWatcher' incorrectly implements interface 'import("fs").FSWatcher'.
Type 'FSWatcher' is missing the following properties from type 'FSWatcher': ref, unref
FILE D:/Projects/PROJECT/node_modules/vite/dist/node/index.d.ts:68:15

66 | // Inlined to avoid extra dependency (chokidar is bundled in the published build)
67 |

68 | declare class FSWatcher extends EventEmitter implements fs.FSWatcher {
| ^^^^^^^^^
69 | options: WatchOptions
70 |
71 | /**

Additional context

Not 100% certain if this is the perfect fix, but adding the same two methods to vite/dist/node/index.d.ts allowed build to complete successfully. (Sorry, First time contributing, have read guidelines but nearly certainly have missed something!)


What is the purpose of this pull request?

  • Bug fix
  • New Feature
  • Documentation update
  • Other

Before submitting the PR, please make sure you do the following

  • Read the Contributing Guidelines, especially the Pull Request Guidelines.
  • Check that there isn't already a PR that solves the problem the same way to avoid creating a duplicate.
  • Provide a description in this PR that addresses what the PR is solving, or reference the issue that it solves (e.g. fixes #123).
  • Update the corresponding documentation if needed.
  • Ideally, include relevant tests that fail without this PR but pass with it.

Copy link

stackblitz bot commented Jan 24, 2024

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@saerich saerich changed the title fix: Add ref() and unref() to chokidar.d.ts for typescript build to work. fix: add ref() and unref() to chokidar.d.ts for typescript build to work. Jan 24, 2024
@saerich saerich marked this pull request as draft January 24, 2024 14:43
@hi-ogawa
Copy link
Collaborator

hi-ogawa commented Jan 25, 2024

There are some details in:

Probably this happens for users who upgraded to @types/node@20.11.6 without skipLibCheck: true. For example, Vitest's typecheck template also hits this https://stackblitz.com/edit/vitest-dev-vitest-jdc2r7?file=package.json (from https://github.com/vitest-dev/vitest/blob/main/examples/README.md).

@patak-dev
Copy link
Member

Thanks for investigating this @hi-ogawa! Let's wait a bit to see what they decide to do in:

Copy link
Member

@bluwy bluwy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure when chokidar will be able to resolve the issue, but I think anyways chokidar will have to do the same fix here as ref/unref had long existed in node12/14, so leaving my approval here for now.

@patak-dev
Copy link
Member

Ok, let's merge this then 👍🏼

@patak-dev patak-dev merged commit 6b45037 into vitejs:main Jan 29, 2024
10 checks passed
@mgdodge
Copy link

mgdodge commented Feb 6, 2024

Seeing as the problematic node type update has broken every version of vite that runs with up-to-date node type definitions, is there any chance of this fix getting backported to the 4.x branch? I can't be the only one with multiple build jobs that are still running things in that range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants