microsoft / microsoft/TypeScript
Behavior difference: Type emit inconsistency with dangling block comment in file
@jakebailey がすでに取り組んでいます。
2026年6月16日 から。
- 主要言語
- Go
- スター
- 111k
- フォーク
- 14.3k
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 132
説明
Summary as below. I call this situation _dangling block comment_, since there are more than just newlines in between the block comments and the attached variables in the code.
Note that a fix for `top, .ts` will be a breaking change from TS 6.
| | tsc | tsgo |
|-------------|---------------------------------------------------|---------------------------------------------------|
| nonTop, .js | ✅ Dangling comment erased | ✅ Dangling comment erased |
| nonTop, .ts | ✅ Dangling comment erased | ✅ Dangling comment erased |
| top, .js | ✅ Dangling comment erased | ❌ Dangling comment attached to incorrect variable |
| top, .ts | ❌ Dangling comment attached to incorrect variable | ❌ Dangling comment attached to incorrect variable |
---
## Steps to reproduce
1. Start a plain new project
- "@typescript/native-preview": "7.0.0-dev.20260612.1",
- "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,
- "removeComments": false,
3. Add the below files. Run `npx tsc` & `npx tsgo` to see the difference.
```ts
/** ========> src/nonTopComment-js.js <======== */
export const e = 3;
/** Comment on nothing */
/** Comment on noop */
(function noop() {})();
export const pi = 3;
/** ========> src/nonTopComment-ts.ts <======== */
export const e = 3;
/** Comment on nothing */
/** Comment on noop */
(function noop() {})();
export const pi = 3;
/** ========> src/topComment-js.js <======== */
/** Comment on nothing */
/** Comment on noop */
(function noop() {})();
export const pi = 3;
/** ========> src/topComment-ts.ts <======== */
/** Comment on nothing */
/** Comment on noop */
(function noop() {})();
export const pi = 3;
```
## Behavior with `typescript@6.0`
```ts
/** ========> dist/nonTopComment-js.d.ts <======== */
export const e: 3;
export const pi: 3;
//# sourceMappingURL=nonTopComment-js.d.ts.map
/** ========> dist/nonTopComment-ts.d.ts <======== */
export declare const e = 3;
export declare const pi = 3;
//# sourceMappingURL=nonTopComment-ts.d.ts.map
/** ========> dist/topComment-js.d.ts <======== */
export const pi: 3;
//# sourceMappingURL=topComment-js.d.ts.map
/** ========> dist/topComment-ts.d.ts <======== */
/** Comment on nothing */
export declare const pi = 3;
//# sourceMappingURL=topComment-ts.d.ts.map
```
## Behavior with `tsgo`
```ts
/** ========> dist/nonTopComment-js.d.ts <======== */
export declare const e = 3;
export declare const pi = 3;
//# sourceMappingURL=nonTopComment-js.d.ts.map
/** ========> dist/nonTopComment-ts.d.ts <======== */
export declare const e = 3;
export declare const pi = 3;
//# sourceMappingURL=nonTopComment-ts.d.ts.map
/** ========> dist/topComment-js.d.ts <======== */
/** Comment on nothing */
export declare const pi = 3;
//# sourceMappingURL=topComment-js.d.ts.map
/** ========> dist/topComment-ts.d.ts <======== */
/** Comment on nothing */
export declare const pi = 3;
//# sourceMappingURL=topComment-ts.d.ts.map
```
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。