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
TypeScript Version: 3.7.2
Search Terms: RegExpMatchArray, input, index, length, regexp, regex, result objects
Code
Expected behavior: It to work.
Actual behavior: Type checks fails because
RegExpMatchArraydoes not defineindexandinputPlayground Link: Playground Link
Related Issues: none
For reference of the
indexandinputproperties, see:https://github.com/tc39/proposal-regexp-named-groups