-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
QuestionAn issue which isn't directly actionable in codeAn issue which isn't directly actionable in code