anymatch
anymatch copied to clipboard
Update Typescript Declarations index.d.ts
Details:
- Add @types/picomatch as dependency, and import {PicomatchOptions} from "picomatch".
- 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.