From a47c47611f6be54e86454a45e90bd89a270597fc Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 9 Feb 2017 15:25:49 -0800 Subject: [PATCH] Respond to code review comments --- src/compiler/checker.ts | 6 ++---- src/compiler/utilities.ts | 5 +++++ 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 6b49b0bdb93..88f4b1bfe6b 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -5226,7 +5226,7 @@ namespace ts { let hasThisParameter: boolean; const iife = getImmediatelyInvokedFunctionExpression(declaration); const isJSConstructSignature = isJSDocConstructSignature(declaration); - const isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && isInJavaScriptFile(declaration); + const isUntypedSignatureInJSFile = !iife && !isJSConstructSignature && isInJavaScriptFile(declaration) && !hasJSDocParamterTags(declaration); // If this is a JSDoc construct signature, then skip the first parameter in the // parameter list. The first parameter represents the return type of the construct @@ -5252,13 +5252,11 @@ namespace ts { hasLiteralTypes = true; } - const isUntypedParamInJSFile = isUntypedSignatureInJSFile && !param.type && !getJSDocParameterTags(param); - // Record a new minimum argument count if this is not an optional parameter const isOptionalParameter = param.initializer || param.questionToken || param.dotDotDotToken || iife && parameters.length > iife.arguments.length && !param.type || isJSDocOptionalParameter(param) || - isUntypedParamInJSFile; + isUntypedSignatureInJSFile; if (!isOptionalParameter) { minArgumentCount = parameters.length; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 01cfcb08047..9935c2fb849 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1518,6 +1518,11 @@ namespace ts { return map(getJSDocs(node), doc => doc.comment); } + export function hasJSDocParamterTags(node: FunctionLikeDeclaration | SignatureDeclaration) { + const parameterTags = getJSDocTags(node, SyntaxKind.JSDocParameterTag); + return parameterTags && parameterTags.length > 0; + } + function getJSDocTags(node: Node, kind: SyntaxKind): JSDocTag[] { const docs = getJSDocs(node); if (docs) {