[L]ooking a little closely at the ECMAScript spec, I do think that there is a mismatch between what we have and what gets created in the runtime. RegExpBuiltinExec says that the following are created unconditionally:
- an
index property
- an
input property
- a property at index
0
- a
groups property that is always set, but may be undefined
So RegExpExecArray should look something kind of like
// src/lib/es5.d.ts
interface RegExpExecArray extends Array<string> {
// always present
index: number;
// always present
input: string;
// always present - helpful for '--noUncheckedIndexedAccess'
0: string;
}
// src/lib/es2018.regexp.d.ts
interface RegExpExecArray extends Array<string> {
// always present - helpful for '--exactOptionalPropertyTypes'
groups: { [key: string]: string } | undefined;
}
Derived from content posted by Daniel Rosenwasser (@DanielRosenwasser) in #50211 (comment)
In additionl to the above, it seems like RegExpMatchArray/RegExpExecArray are sometimes both returned from functions that undergo the same internal code paths. So we should probably ensure that one is compatible with the other, and have a test that ensures as much.
[L]ooking a little closely at the ECMAScript spec, I do think that there is a mismatch between what we have and what gets created in the runtime.
RegExpBuiltinExecsays that the following are created unconditionally:indexpropertyinputproperty0groupsproperty that is always set, but may beundefinedSo
RegExpExecArrayshould look something kind of likeDerived from content posted by Daniel Rosenwasser (@DanielRosenwasser) in #50211 (comment)
In additionl to the above, it seems like
RegExpMatchArray/RegExpExecArrayare sometimes both returned from functions that undergo the same internal code paths. So we should probably ensure that one is compatible with the other, and have a test that ensures as much.