microsoft / microsoft/TypeScript
`String.prototype.split()` with a regex containing a capturing group can return an array of `string | undefined`.
Personne n'a encore pris cette issue.
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.4k
- Merge moyen
- 1 j 19 h
- PR mergées (30 j)
- 117
Description
⚙ 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
Guide de contribution
Ouvrir le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
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.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- typescript
- Domaine
- compilers
- Type d'issue
- Bug
- Difficulté
- 3/5
- Temps estimé
- 1-2 jours
- Activité
- À l'abandon
- Clarté
- Plutôt claire
- Accessibilité débutants
- 45/100