microsoft / microsoft/TypeScript
String.split() method's separator argument should allow undefined
- Langage dominant
- Go
- Étoiles
- 111k
- Forks
- 14.3k
- Merge moyen
- 2 j 4 h
- PR mergées (30 j)
- 132
Description
### ⚙ Compilation target
ES2024
### ⚙ Library
6.0.2
### Missing / Incorrect Definition
String.split should allow undefined as its separator argument, resulting in an array containing the entire string.
Unlike the case of omitting the separator (#38331), this is a useful feature, since separator may be a variable, and it can be desirable to get an array with the entire string in the case that separator is not set, in order to not need a different code path for this case.
This feature is explicitly defined in the spec. It is not something that just 'happens to work', like using null or a number.
### Sample Code
```TypeScript
console.log("string,that could/split:but-should;not".split(undefined));
```
### Documentation Link
https://tc39.es/ecma262/multipage/text-processing.html#sec-string.prototype.split
Guide de contribution
Ouvrir le guide de contribution
Piste de recherche
Examinez la déclaration de String.split par rapport à la spécification ECMAScript liée, en vous concentrant sur l’argument separator et l’exemple fourni. Le travail est considéré comme terminé lorsque la définition TypeScript accepte undefined et que l’exemple passe la vérification des types sans nécessiter un chemin de code distinct.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- javascript, typescript
- Domaine
- tooling
- Type d'issue
- Bug
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Activité
- Calme
- Clarté
- Clairement spécifiée
- Accessibilité débutants
- 68/100