microsoft / microsoft/TypeScript

Behavior difference: Type emit inconsistency with dangling block comment in file

Abierto
#63,837 0 comentarios 1 reacción 2 asignados Ver en GitHub

@jakebailey ya está trabajando en esto.

Desde el 16/6/2026.

Possible Improvement
Lenguaje dominante
Go
Estrellas
111k
Forks
14.3k
Merge medio
2 d 4 h
PR fusionados (30 d)
132

Descripción

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.
/** ========> 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

/** ========> 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

/** ========> 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

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.