Skip to content

Bug: RegExpMatchArray is missing properties index and input #35157

@balupton

Description

@balupton

TypeScript Version: 3.7.2

Search Terms: RegExpMatchArray, input, index, length, regexp, regex, result objects

Code

const match = 'a'.match(/a/)
if ( match ) console.log(match.input.includes('a'), match.index.toFixed(2))

Expected behavior: It to work.

Actual behavior: Type checks fails because RegExpMatchArray does not define index and input

Playground Link: Playground Link

Related Issues: none

For reference of the index and input properties, see:

RegExp result objects have some non-numerical properties already, which named capture groups may overlap with, namely length, index and input.

https://github.com/tc39/proposal-regexp-named-groups

Metadata

Metadata

Assignees

No one assigned

    Labels

    QuestionAn issue which isn't directly actionable in code

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions