Merge pull request #16696 from Microsoft/fix15663

Ignore jsdoc when inferring rest args in JavaScript
This commit is contained in:
Ron Buckton
2017-06-30 14:27:55 -07:00
committed by GitHub
2 changed files with 3 additions and 3 deletions

View File

@@ -6398,7 +6398,7 @@ namespace ts {
undefined;
// JS functions get a free rest parameter if they reference `arguments`
let hasRestLikeParameter = hasRestParameter(declaration);
if (!hasRestLikeParameter && isInJavaScriptFile(declaration) && !hasJSDocParameterTags(declaration) && containsArgumentsReference(declaration)) {
if (!hasRestLikeParameter && isInJavaScriptFile(declaration) && containsArgumentsReference(declaration)) {
hasRestLikeParameter = true;
const syntheticArgsSymbol = createSymbol(SymbolFlags.Variable, "args");
syntheticArgsSymbol.type = anyArrayType;

View File

@@ -35,13 +35,13 @@ someRest(1, 2, 3);
* @param {number} x - a thing
*/
function jsdocced(x) { arguments; }
>jsdocced : (x: number) => void
>jsdocced : (x: number, ...args: any[]) => void
>x : number
>arguments : IArguments
jsdocced(1);
>jsdocced(1) : void
>jsdocced : (x: number) => void
>jsdocced : (x: number, ...args: any[]) => void
>1 : 1
function dontDoubleRest(x, ...y) { arguments; }