Skip to content

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

@themaxdavitt

Description

@themaxdavitt

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;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions