Skip to content

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