microsoft / microsoft/TypeScript
Missing computed properties in declaration emit
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
With #60052, we now emit qualified names rather than generate an index signature for computed names in classes; however, this now puts us in an awkward place where regardless of errors, declaration emit diverges on `isolatedDeclarations`.
Playground Links:
* [5.7, without `isolatedDeclarations`](https://www.typescriptlang.org/play/?isolatedDeclarations=false&ts=5.7.3#code/KYDwDg9gTgLgBAYwgOwM7wOZWMGBLZDALjgFdk8BHU4OVATwFsAjCAGzgF44BlJ1tgAoAlAG4AUKEixEKdLPIwS5KjTr92XXhqFjxk8NHgI2AQ1So4AWXoBhMxYCMcAN7i4HuAG0sOfIQBdEnQoAgwtACIAd2g2ABMIiU9vJEUguGRSFmAoLQAWACYJAF99KSM4YEzGOAAFKAgwHJh6ADlTRmBLN2TfXDDIvv8MCIAad09U5HhuCKmYMfFSg2ljB0sbe3NUAtcJjy96xua2jq6AOiGw9JCB2ZioeMT97yOm2FPO1HP59OrmHL5IpLMqGGRsXBwMANMAAQmCMFChAkKwqJm21js6wAzHtkl5oY10iIuAA+OAANwgeDiWhJnHJLlKpSAA)
* [Nightly, without `isolatedDeclarations`](https://www.typescriptlang.org/play/?isolatedDeclarations=false&ts=5.8.0-dev.20250128#code/KYDwDg9gTgLgBAYwgOwM7wOZWMGBLZDALjgFdk8BHU4OVATwFsAjCAGzgF44BlJ1tgAoAlAG4AUKEixEKdLPIwS5KjTr92XXhqFjxk8NHgI2AQ1So4AWXoBhMxYCMcAN7i4HuAG0sOfIQBdEnQoAgwtACIAd2g2ABMIiU9vJEUguGRSFmAoLQAWACYJAF99KSM4YEzGOAAFKAgwHJh6ADlTRmBLN2TfXDDIvv8MCIAad09U5HhuCKmYMfFSg2ljB0sbe3NUAtcJjy96xua2jq6AOiGw9JCB2ZioeMT97yOm2FPO1HP59OrmHL5IpLMqGGRsXBwMANMAAQmCMFChAkKwqJm21js6wAzHtkl5oY10iIuAA+OAANwgeDiWhJnHJLlKpSAA)
* [Nightly, with `isolatedDeclarations`](https://www.typescriptlang.org/play/?isolatedDeclarations=true&ts=5.8.0-dev.20250128#code/KYDwDg9gTgLgBAYwgOwM7wOZWMGBLZDALjgFdk8BHU4OVATwFsAjCAGzgF44BlJ1tgAoAlAG4AUKEixEKdLPIwS5KjTr92XXhqFjxk8NHgI2AQ1So4AWXoBhMxYCMcAN7i4HuAG0sOfIQBdEnQoAgwtACIAd2g2ABMIiU9vJEUguGRSFmAoLQAWACYJAF99KSM4YEzGOAAFKAgwHJh6ADlTRmBLN2TfXDDIvv8MCIAad09U5HhuCKmYMfFSg2ljB0sbe3NUAtcJjy96xua2jq6AOiGw9JCB2ZioeMT97yOm2FPO1HP59OrmHL5IpLMqGGRsXBwMANMAAQmCMFChAkKwqJm21js6wAzHtkl5oY10iIuAA+OAANwgeDiWhJnHJLlKpSAA)
```ts
export const greeting: unique symbol = Symbol();
export const count: unique symbol = Symbol();
export class MyClass1 {
[greeting]: string = "world";
[count]: number = 42;
}
export enum PropertyNames {
greeting = "greeting",
count = "count",
}
export class MyClass2 {
[PropertyNames.greeting]: string = "world";
[PropertyNames.count]: number = 42;
}
export let prop!: string;
export class MyClass3 {
[prop]: () => void = () => {}
}
```
Compared to `--isolatedDeclarations false` The declaration emit lacks expected contents in `MyClass1` and `MyClass2`:
```diff lang=ts
export declare const greeting: unique symbol;
export declare const count: unique symbol;
export declare class MyClass1 {
- [greeting]: string;
- [count]: number;
}
export declare enum PropertyNames {
greeting = "greeting",
count = "count"
}
export declare class MyClass2 {
- [PropertyNames.greeting]: string;
- [PropertyNames.count]: number;
}
export declare let prop: string;
export declare class MyClass3 {
[prop]: () => void;
}
```
It is surprising that `prop` is emitted regardless of `--isolatedDeclarations`, but not the other contents.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 Playground 链接中展示的 TypeScript 声明发出行为开始,比较 MyClass1、MyClass2 和 MyClass3 在有无 --isolatedDeclarations 时的输出。跟踪计算属性的处理,并确保声明发出保留预期的计算属性,同时保持当前的 prop 行为;根据示例检查发出的声明差异。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 基本清楚
- 新手友好度
- 35/100