Closed
Description
TypeScript Version: 3.9.1-rc
Search Terms: jsdoc, varargs, declaration
Code
vararg.js
:
/**
* @param {!Object<string, function(string, ...*):*>} formatter
* @param {string} format
* @param {...*} var_args
*/
function takesVarargs(formatter, format, ...var_args) {
formatter['pattern'](format, var_args);
}
tsconfig.json
:
{
"compilerOptions": {
"module": "esnext",
"target": "esnext",
"outDir": "lib",
"declaration": true,
"allowJs": true,
"checkJs": true
},
"files": [
"vararg.js"
]
}
Expected behavior:
(Run with TypeScript 3.8.3)
/**
* @param {!Object<string, function(string, ...*):*>} formatter
* @param {string} format
* @param {...*} var_args
*/
declare function takesVarargs(formatter: {
[x: string]: (arg0: string, ...arg1: any[]) => any;
}, format: string, ...var_args: any[]): void;
Actual behavior:
(Run with TypeScript 3.9.1-rc)
/**
* @param {!Object<string, function(string, ...*):*>} formatter
* @param {string} format
* @param {...*} var_args
*/
declare function takesVarargs(formatter: {
[x: string]: (arg0: string, arg1: ...*) => any;
}, format: string, ...var_args: ...*): void;
Note that the function arguments varargs are not properly changed to ...arg1: any[]
anymore and are now only arg1: ...*
. This means that a subsequent composite
usage of this declaration file will crash, as the syntax is not valid.
Playground Link: n/a as Playground doesn't allow me to show the declaration files if the language=JavaScript
. Instead it shows me // Using JavaScript, no compilation needed.
Related Issues: A wild guess that #37757 might be related?