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: Matcher for chokidar WatchOptions#ignored #4616

Merged
merged 3 commits into from Aug 16, 2021
Merged

fix: Matcher for chokidar WatchOptions#ignored #4616

merged 3 commits into from Aug 16, 2021

Conversation

hyf0
Copy link
Contributor

@hyf0 hyf0 commented Aug 15, 2021

Description

Make type def more accurate.

Additional context


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.
  • Read the Pull Request Guidelines and follow the Commit Convention.
  • 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).
  • Ideally, include relevant tests that fail without this PR but pass with it.

@Shinigami92 Shinigami92 added the p1-chore Doesn't change code behavior (priority) label Aug 15, 2021
Shinigami92
Shinigami92 previously approved these changes Aug 15, 2021
@@ -117,7 +117,7 @@ export interface WatchOptions {
* (the path), second time with two arguments (the path and the
* [`fs.Stats`](https://nodejs.org/api/fs.html#fs_class_fs_stats) object of that path).
*/
ignored?: any
ignored?: string[]
Copy link
Member

Choose a reason for hiding this comment

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

Looks like ignored can also be of type string when only one entry is needed, or a regex. I don't find proper docs for it, maybe it is better to first send this change to chokidar so it is properly discussed there, and then we can port it here?

Copy link
Contributor Author

@hyf0 hyf0 Aug 16, 2021

Choose a reason for hiding this comment

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

Yes, you are right. But it seems to introduce another problem. we make the assumption that it is just an array. It will be throw error '/foo/ is not iterable' if the user just writes ignore: /foo/.

const { ignored = [], ...watchOptions } = serverConfig.watch || {}
const watcher = chokidar.watch(path.resolve(root), {
ignored: ['**/node_modules/**', '**/.git/**', ...ignored],

I will close this and open another PR to fix it. Thanks for all the guidance.

@hyf0
Copy link
Contributor Author

hyf0 commented Aug 16, 2021

wow. Not expected PR(paulmillr/chokidar#1140) being merged immediately.

@hyf0 hyf0 reopened this Aug 16, 2021
@hyf0 hyf0 changed the title types(vite): replace any with string[] for chokidar WatchOptions#ignored types(vite): replace any with Matcher for chokidar WatchOptions#ignored Aug 16, 2021
@hyf0
Copy link
Contributor Author

hyf0 commented Aug 16, 2021

Warning: types/chokidar.d.ts:124:3 - (ae-forgotten-export) The symbol "AnymatchMatcher" needs to be exported by the entry point index.d.ts

API Extractor completed with warnings

The warning is killing me. I couldn't solve it by reading the warning and doc. Simply re-export it in ' types/chokidar.d.ts' doesn't solve the problem and I fail to find location of entry point index.d.ts.


exporting warning types from packages/vite/src/node/index.ts solve it.

@patak-dev patak-dev changed the title types(vite): replace any with Matcher for chokidar WatchOptions#ignored fix: Matcher for chokidar WatchOptions#ignored Aug 16, 2021
@patak-dev patak-dev merged commit 89e7a41 into vitejs:main Aug 16, 2021
@patak-dev patak-dev added p3-minor-bug An edge case that only affects very specific usage (priority) and removed p1-chore Doesn't change code behavior (priority) labels Aug 16, 2021
aleclarson pushed a commit to aleclarson/vite that referenced this pull request Nov 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants