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

Can't use Picomatch options with returnIndex in TypeScript #40

Open
themaxdavitt opened this issue Apr 30, 2021 · 1 comment
Open

Can't use Picomatch options with returnIndex in TypeScript #40

themaxdavitt opened this issue Apr 30, 2021 · 1 comment

Comments

@themaxdavitt
Copy link

themaxdavitt commented Apr 30, 2021

I was trying to do something like this:

const processorIndex = anymatch(this.processorGlobs, relativePath, {
    dot: true,
    returnIndex: true
});

But I get the following error:

error TS2345: Argument of type '{ dot: true; returnIndex: boolean; }' is not assignable to parameter of type 'true | PicomatchOptions'.
  Object literal may only specify known properties, and 'returnIndex' does not exist in type 'PicomatchOptions'.

26             returnIndex: true
               ~~~~~~~~~~~~~~~~~


Found 1 error.

I think the typings should be changed to allow this, e.g.:

-(matchers: AnymatchMatcher, testString: string|any[], returnIndex: true | PicomatchOptions): number;
+(matchers: AnymatchMatcher, testString: string|any[], returnIndex: true | PicomatchOptions & { returnIndex?: boolean }): number;
@OrbintSoft OrbintSoft mentioned this issue Mar 15, 2023
@paul-vd
Copy link

paul-vd commented Apr 18, 2024

The docs is misleading, it indicates we can use PicomatchOptions, but the type is hardcoded to either be returnIndex:true or {dot:boolean}

https://github.com/micromatch/anymatch/blob/master/index.d.ts#L9

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

No branches or pull requests

2 participants