microsoft / microsoft/TypeScript

Behavior difference: (jsdoc) comment emit inconsistencies on expando functions

Offen
#63,836 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Possible Improvement
Vorherrschende Sprache
Go
Sterne
111k
Forks
14.3k
Ø Merge
2 T. 4 Std.
Gemergte PRs (30 T.)
132

Beschreibung

Summary as below. Note that the commit emit fix for arrows will be a breaking change from TS 6.

| | tsc + `.js` | tsc + `.ts` | tsgo + `.js` | tsgo + `.ts` |
|----------------------------------|-------------|-------------|--------------|--------------|
| ExpandoFunctionInlineNamedExport | ✅ Comment | ✅ Comment | ✅ Comment | ✅ Comment |
| ExpandoArrowInlineNamedExport | ❌ Comment | ✅ Comment | ❌ Comment | ❌ Comment |
| ExpandoFunctionNamedExport | ✅ Comment | ✅ Comment | ✅ Comment | ✅ Comment |
| ExpandoArrowNamedExport | ✅ Comment | ✅ Comment | ❌ Comment | ❌ Comment |
| ExpandoFunctionDefaultExport | ✅ Comment | ✅ Comment | ✅ Comment | ✅ Comment |
| ExpandoArrowDefaultExport | ✅ Comment | ✅ Comment | ❌ Comment | ❌ Comment |

---

## 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.
- Emitted type output from using `.js` and `.ts` are a bit different as shown above.

src/main.js

```js
/**
* jsdoc description on `ExpandoFunctionInlineNamedExport`
*/
export function ExpandoFunctionInlineNamedExport() { return null; }
ExpandoFunctionInlineNamedExport.args = { num: 3 };

/**
* jsdoc description on `ExpandoArrowInlineNamedExport`
*/
export const ExpandoArrowInlineNamedExport = () => { return null; };
ExpandoArrowInlineNamedExport.args = { num: 3 };

/**
* jsdoc description on `ExpandoFunctionNamedExport`
*/
function ExpandoFunctionNamedExport() { return null; }
ExpandoFunctionNamedExport.args = { num: 3 };

/**
* jsdoc description on `ExpandoArrowNamedExport`
*/
const ExpandoArrowNamedExport = () => { return null; };
ExpandoArrowNamedExport.args = { num: 3 };

export { ExpandoFunctionNamedExport, ExpandoArrowNamedExport };

```

src/ExpandoFunctionDefaultExport.js

```js
/**
* jsdoc description on `ExpandoFunctionDefaultExport`
*/
function ExpandoFunctionDefaultExport() { return null; }
ExpandoFunctionDefaultExport.args = { num: 3 };

export default ExpandoFunctionDefaultExport;
```

src/ExpandoArrowDefaultExport.js

```js
/**
* jsdoc description on `ExpandoArrowDefaultExport`
*/
const ExpandoArrowDefaultExport = () => { return null; };
ExpandoArrowDefaultExport.args = { num: 3 };

export default ExpandoArrowDefaultExport;
```

## Behavior with `typescript@6.0`

Output from using `.js`.

```ts
/**
* jsdoc description on `ExpandoFunctionInlineNamedExport`
*/
export function ExpandoFunctionInlineNamedExport(): null;
export namespace ExpandoFunctionInlineNamedExport {
namespace args {
let num: number;
}
}
export function ExpandoArrowInlineNamedExport(): null;
export namespace ExpandoArrowInlineNamedExport {
export namespace args_1 {
let num_1: number;
export { num_1 as num };
}
export { args_1 as args };
}
/**
* jsdoc description on `ExpandoFunctionNamedExport`
*/
export function ExpandoFunctionNamedExport(): null;
export namespace ExpandoFunctionNamedExport {
export namespace args_2 {
let num_2: number;
export { num_2 as num };
}
export { args_2 as args };
}
/**
* jsdoc description on `ExpandoArrowNamedExport`
*/
export function ExpandoArrowNamedExport(): null;
export namespace ExpandoArrowNamedExport {
export namespace args_3 {
let num_3: number;
export { num_3 as num };
}
export { args_3 as args };
}
//# sourceMappingURL=main.d.ts.map

export default ExpandoFunctionDefaultExport;
/**
* jsdoc description on `ExpandoFunctionDefaultExport`
*/
declare function ExpandoFunctionDefaultExport(): null;
declare namespace ExpandoFunctionDefaultExport {
namespace args {
let num: number;
}
}
//# sourceMappingURL=ExpandoFunctionDefaultExport.d.ts.map

export default ExpandoArrowDefaultExport;
/**
* jsdoc description on `ExpandoArrowDefaultExport`
*/
declare function ExpandoArrowDefaultExport(): null;
declare namespace ExpandoArrowDefaultExport {
namespace args {
let num: number;
}
}
//# sourceMappingURL=ExpandoArrowDefaultExport.d.ts.map
```

## Behavior with `tsgo`

Output from using `.js`.

```ts
/**
* jsdoc description on `ExpandoFunctionInlineNamedExport`
*/
export declare function ExpandoFunctionInlineNamedExport(): null;
export declare namespace ExpandoFunctionInlineNamedExport {
var args: {
num: number;
};
}
export declare function ExpandoArrowInlineNamedExport(): null;
export declare namespace ExpandoArrowInlineNamedExport {
var args: {
num: number;
};
}
/**
* jsdoc description on `ExpandoFunctionNamedExport`
*/
declare function ExpandoFunctionNamedExport(): null;
declare namespace ExpandoFunctionNamedExport {
var args: {
num: number;
};
}
declare function ExpandoArrowNamedExport(): null;
declare namespace ExpandoArrowNamedExport {
var args: {
num: number;
};
}
export { ExpandoFunctionNamedExport, ExpandoArrowNamedExport };
//# sourceMappingURL=main.d.ts.map

/**
* jsdoc description on `ExpandoFunctionDefaultExport`
*/
declare function ExpandoFunctionDefaultExport(): null;
declare namespace ExpandoFunctionDefaultExport {
var args: {
num: number;
};
}
export default ExpandoFunctionDefaultExport;
//# sourceMappingURL=ExpandoFunctionDefaultExport.d.ts.map

declare function ExpandoArrowDefaultExport(): null;
declare namespace ExpandoArrowDefaultExport {
var args: {
num: number;
};
}
export default ExpandoArrowDefaultExport;
//# sourceMappingURL=ExpandoArrowDefaultExport.d.ts.map
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne mit den vier Quelldateien unter src/ und reproduziere die Deklarationsausgabe mit tsc und tsgo, wobei allowJs, checkJs, stableTypeOrdering und removeComments deaktiviert sind. Vergleiche die JSDoc-Ausgabe für die function- und arrow-expando-Exporte bei benannten und default-Exporten; abgeschlossen ist die Aufgabe, wenn die Ausgaben einem konsistenten, vereinbarten Verhalten folgen.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
go, javascript, typescript
Bereich
compilers
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Ruhig
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
45/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.