microsoft / microsoft/TypeScript
Behavior difference: Block comments on `@typedef` structural types are not preserved, if they are imported and reconstructed as inline types in another file
还没有人认领这个 Issue。
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
A follow-up on https://github.com/microsoft/typescript-go/issues/4235.
---
## Steps to reproduce
1. Start a plain new project
- "@typescript/native-preview": "7.0.0-dev.20260617.2",
- "typescript": "6.0.3"
2. Run `npx tsgo --init` to get the default tsconfig. Turn on these flags as well.
- "allowJs": true,
- "checkJs": true,
- "stableTypeOrdering": true,
3. Add the below files. Run `npx tsc` & `npx tsgo` to see the difference.
```ts
/** ========> src/lib.js <======== */
/**
* @typedef {Object} Foo
* @property {boolean} bool Whether `.bool` is true or not
*/
export class C {
/** @returns {Foo} */
getFoo() { return { bool: false }; }
/**
* @typedef {Object} Bar
* @property {boolean} bool Whether `.bool` is true or not
*/
/** @returns {Bar} */
getBar() { return { bool: false }; }
}
/** ========> src/mainJs.js <======== */
import { C } from './lib.js';
export class MainJs {
constructor() {
this.c = new C();
};
getFoo() { return { ...this.c.getFoo() }; }
getBar() { return { ...this.c.getBar() }; }
}
/** ========> src/mainTs.ts <======== */
import { C } from './lib.js';
export class MainTs {
constructor(public c: C) {};
getFoo() { return { ...this.c.getFoo() }; }
getBar() { return { ...this.c.getBar() }; }
}
```
## Behavior with `typescript@6.0`
```ts
/** ========> dist/mainJs.d.ts <======== */
export class MainJs {
c: C;
getFoo(): {
/**
* Whether `.bool` is true or not
*/
bool: boolean;
};
getBar(): {
/**
* Whether `.bool` is true or not
*/
bool: boolean;
};
}
import { C } from './lib.js';
/** ========> dist/mainTs.d.ts <======== */
import { C } from './lib.js';
export declare class MainTs {
c: C;
constructor(c: C);
getFoo(): {
/**
* Whether `.bool` is true or not
*/
bool: boolean;
};
getBar(): {
/**
* Whether `.bool` is true or not
*/
bool: boolean;
};
}
```
## Behavior with `tsgo`
```ts
/** ========> dist/mainJs.d.ts <======== */
import { C } from './lib.js';
export declare class MainJs {
c: C;
constructor();
getFoo(): {
bool: boolean;
};
getBar(): {
bool: boolean;
};
}
/** ========> dist/mainTs.d.ts <======== */
import { C } from './lib.js';
export declare class MainTs {
c: C;
constructor(c: C);
getFoo(): {
bool: boolean;
};
getBar(): {
bool: boolean;
};
}
```
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
启用 allowJs、checkJs 和 stableTypeOrdering,使用 src/lib.js、src/mainJs.js 和 src/mainTs.ts 重现差异,然后运行 npx tsc 和 npx tsgo。比较生成的 dist/mainJs.d.ts 和 dist/mainTs.d.ts 文件;当重构的内联类型在两个输出中都保留 @property 注释时,修复即完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- go, javascript, typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 冷清
- 描述清晰度
- 基本清楚
- 新手友好度
- 45/100