-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptEffort: CasualGood issue if you're already used to contributing to the codebase. Harder than "good first issue".Good issue if you're already used to contributing to the codebase. Harder than "good first issue".Help WantedYou can do thisYou can do this
Milestone
Description
[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
indexproperty - an
inputproperty - a property at index
0 - a
groupsproperty that is always set, but may beundefined
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 @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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptDomain: lib.d.tsThe issue relates to the different libraries shipped with TypeScriptThe issue relates to the different libraries shipped with TypeScriptEffort: CasualGood issue if you're already used to contributing to the codebase. Harder than "good first issue".Good issue if you're already used to contributing to the codebase. Harder than "good first issue".Help WantedYou can do thisYou can do this