-
Notifications
You must be signed in to change notification settings - Fork 12.9k
Closed
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue
Milestone
Description
TypeScript Version: 4.0.0-dev.20200512
Search Terms: jsdoc, declaration, varargs
Code
clazz.js
:
export class Clazz {
/**
* @param {function(this:Object, ...*):*} functionDeclaration
*/
method(functionDeclaration) {}
}
tsconfig.json
:
{
"compilerOptions": {
"outDir": "lib",
"declaration": true,
"allowJs": true,
"checkJs": true
},
"files": [
"clazz.js"
]
}
Expected behavior:
The emitted declaration file is:
export class Clazz {
/**
* @param {function(this:Object, ...*):*} functionDeclaration
*/
method(functionDeclaration: (...args: any[]) => any): void;
}
Actual behavior:
export class Clazz {
/**
* @param {function(this:Object, ...*):*} functionDeclaration
*/
method(functionDeclaration: (args: any, ...args: any[]) => any): void;
}
Subsequent usages of a composite project break, as args
is duplicated in the method argument types.
Note that removal of this:Object
fixes the issue. Also, the following properly emits:
export class Clazz {
/**
* @param {function(this:Object, ...*):T} functionDeclaration
* @template T
*/
method(functionDeclaration) {}
}
Note here that the T
is unused in the function, but it fixes the emitted declaration file.
Playground Link:
Related Issues: #38242 (we are successfully able to compile DevTools with the above workaround and the fix for #38242)
Metadata
Metadata
Assignees
Labels
BugA bug in TypeScriptA bug in TypeScriptFix AvailableA PR has been opened for this issueA PR has been opened for this issue