microsoft / microsoft/TypeScript
No excess property error for computed property
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 1 天 19 小时
- 30 天内合并 PR
- 117
描述
TypeScript Version: 3.7.5 and 3.9.0-dev.20200220
Search Terms: excess property, computed property, index signature
Code
interface Foo {
a: string;
}
const bar: Foo = {
a: "",
z: "" // error, excess prop
}
const baz: Foo = {
a: "",
["Z".toLowerCase()]: "" // this is okay I guess?
}
Expected behavior:
The computed property in the definition of baz should maybe produce an excess property error, since Foo has no string index signature and "Z".toLowerCase() is only known to be a string.
Actual behavior:
The computed property is allowed.
Playground Link: Here
Related Issues: #22427
This issue is a re-opening of #22427, which was marked as a bug and closed as "fixed", but I don't see an actual fix referenced anywhere in that issue and the behavior described in that issue persists. Any ideas? Thanks!
There's an SO question asking this, which brought me to #22427, which has me scratching my head 😕.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 issue 中的 TypeScript Playground 复现开始,并比较计算属性的情况与直接的多余属性情况。阅读相关 issue #22427 以了解之前的讨论;当预期的多余属性行为得到解决,或通过更新后的编译器测试记录了预期行为时,即视为完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100