TypeScript/tests/cases/compiler/jsdocRestParameter.ts
Andy 4b96edf72f
Treat ... in jsdoc type as creating a synthetic rest parameter -- not as an array type (#19483)
* Treat `...` in jsdoc type as creating a synthetic rest parameter -- not as an array type

* Change type parsing so `...T[]` parses as `...(T[])` and not `(...T)[]`

* Replace the last parameter with ...args, and make access to it potentially undefined

* Code review
2017-11-15 13:04:08 -08:00

16 lines
344 B
TypeScript

// @allowJs: true
// @checkJs: true
// @strict: true
// @noEmit: true
// @Filename: /a.js
/** @param {...number} a */
function f(a) {
a; // number | undefined
// Ideally this would be a number. But currently checker.ts has only one `argumentsSymbol`, so it's `any`.
arguments[0];
}
f([1, 2]); // Error
f(1, "2"); // Error
f(1, 2);