microsoft / microsoft/TypeScript
Object spread drops index signature
未关闭
还没有人认领这个 Issue。
In Discussion
Suggestion
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.4k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 117
描述
TypeScript Version: 3.0.1
Search Terms:
spread index signature, spread indexer
Code
declare var v: Record<string, string>;
let v2 = {...v}; // works
let v3 = {a: '', ...v}; // index signature lost
let v4 = {...v, a: ''}; // same as above
let v5 = {a: 1, ...v}; // index signature lost, should be '{a: number, [x: string]: number | string}'
let v6 = {[Number()]: 1, ...v}; // empty object type ò,Ó, should be '{[x: string]: number | string}'
Expected behavior:
Index signature exists on all object types.
Actual behavior:
Index signature is lost if object literal contains another property assignment. I'm not entirely sure what the type of v6 should be.
Related Issues:
#16694
#16373
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 issue 中的 TypeScript 3.0.1 示例开始,通过链接的 Playground 重现推断出的类型。查看相关 issue #16694 和 #16373,了解之前的讨论和预期行为,尤其是 v5 和 v6。对于报告的对象展开案例,建立并实现一致的索引签名行为,并为这些示例提供覆盖,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 39/100