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

Update Typescript Declarations index.d.ts #47

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Starrah
Copy link

@Starrah Starrah commented Mar 14, 2022

Details:

  1. Add @types/picomatch as dependency, and import {PicomatchOptions} from "picomatch".
  2. Add more function signatures to separate different type of return value: when returnIndex=true, the return value is number, otherwise the return value is boolean.

Motivation:
Old type declarations will raise TS complie error when using picomatch options, such as the following code:

import anymatch from "anymatch"
anymatch(matcher, filename, {basename: true}) // // will get TS2345: Argument of type '{ basename: boolean; }' is not assignable to parameter of type 'true | PicomatchOptions'. Object literal may only specify known properties, and 'basename' does not exist in type 'PicomatchOptions'.

With the modifications in this PR, the error is corrected, and the type declaration is matched with what is described in the README.md.

Details:
1. Add @types/picomatch as dependency, and import {PicomatchOptions} from "picomatch".
2. add more function signatures to separate different type of return value: when returnIndex=true, the return value is number, otherwise the return value is boolean.
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.

1 participant