microsoft / microsoft/TypeScript
String.split() method's separator argument should allow undefined
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
### ⚙ 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
贡献指南
调研方向
对照链接的 ECMAScript 规范检查 String.split 的声明,重点关注 separator 参数和提供的示例。完成的标准是 TypeScript 定义接受 undefined,并且示例无需单独的代码路径即可通过类型检查。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, typescript
- 领域
- tooling
- Issue 类型
- 缺陷
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 活跃度
- 冷清
- 描述清晰度
- 描述清楚
- 新手友好度
- 68/100