microsoft / microsoft/TypeScript
Behavior difference: (jsdoc) comment emit inconsistencies on expando functions
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 111k
- Forks
- 14.3k
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 132
Description
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
```
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the four source files under src/ and reproduce the declaration output using tsc and tsgo with allowJs, checkJs, stableTypeOrdering, and removeComments disabled. Compare JSDoc emission for the function and arrow expando exports across named and default exports; done means the outputs follow a consistent, agreed behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, javascript, typescript
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100