microsoft / microsoft/TypeScript
`String.prototype.split()` with a regex containing a capturing group can return an array of `string | undefined`.
Nessuno ha ancora preso questa issue.
- Lingua principale
- Go
- Stelle
- 111k
- Fork
- 14.3k
- Merge medio
- 2g 4h
- PR unite (30g)
- 132
Descrizione
⚙ 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
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- typescript
- Ambito
- compilers
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 45/100