microsoft / microsoft/TypeScript
`String.prototype.split()` with a regex containing a capturing group can return an array of `string | undefined`.
Offen
Dieses Issue hat noch niemand übernommen.
Awaiting More Feedback
Suggestion
- Vorherrschende Sprache
- Go
- Sterne
- 111k
- Forks
- 14.3k
- Ø Merge
- 1 T. 19 Std.
- Gemergte PRs (30 T.)
- 117
Beschreibung
⚙ Compilation target
any
⚙ Library
esnext, dom
Missing / Incorrect Definition
Using split with a negative lookahead and a capturing group can return undefined. See the attached screenshot. When iterating over the array, we lose type safety and encounter runtime errors.
Sample Code
'a,b,c'.split(/,(?!(a))/) // Types as string[]
Documentation Link
No response
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Start at the String.prototype.split entry point in the esnext and dom library definitions and compare its current return type with the sample 'a,b,c'.split(/,(?!(a))/). Check how capturing groups that do not participate are represented at runtime, then add coverage showing that the resulting array type accounts for undefined.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- typescript
- Bereich
- compilers
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Veraltet
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 45/100