From bc3d18fbfcb50e11e82a4aef8c22e293b9ce84a3 Mon Sep 17 00:00:00 2001 From: Andy Hanson Date: Mon, 10 Jul 2017 13:42:59 -0700 Subject: [PATCH] Consistently use `isInJavaScriptFile` helper --- src/compiler/checker.ts | 8 ++++---- src/compiler/utilities.ts | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index ee0a3a90d7e99..705371cda7657 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -4239,7 +4239,7 @@ namespace ts { return addOptionality(declaredType, /*optional*/ declaration.questionToken && includeOptionality); } - if ((noImplicitAny || declaration.flags & NodeFlags.JavaScriptFile) && + if ((noImplicitAny || isInJavaScriptFile(declaration)) && declaration.kind === SyntaxKind.VariableDeclaration && !isBindingPattern(declaration.name) && !(getCombinedModifierFlags(declaration) & ModifierFlags.Export) && !isInAmbientContext(declaration)) { // If --noImplicitAny is on or the declaration is in a Javascript file, @@ -4493,7 +4493,7 @@ namespace ts { if (declaration.kind === SyntaxKind.ExportAssignment) { return links.type = checkExpression((declaration).expression); } - if (declaration.flags & NodeFlags.JavaScriptFile && declaration.kind === SyntaxKind.JSDocPropertyTag && (declaration).typeExpression) { + if (isInJavaScriptFile(declaration) && declaration.kind === SyntaxKind.JSDocPropertyTag && (declaration).typeExpression) { return links.type = getTypeFromTypeNode((declaration).typeExpression.type); } // Handle variable, parameter or property @@ -4552,7 +4552,7 @@ namespace ts { const getter = getDeclarationOfKind(symbol, SyntaxKind.GetAccessor); const setter = getDeclarationOfKind(symbol, SyntaxKind.SetAccessor); - if (getter && getter.flags & NodeFlags.JavaScriptFile) { + if (getter && isInJavaScriptFile(getter)) { const jsDocType = getTypeForDeclarationFromJSDocComment(getter); if (jsDocType) { return links.type = jsDocType; @@ -6206,7 +6206,7 @@ namespace ts { } function isJSDocOptionalParameter(node: ParameterDeclaration) { - if (node.flags & NodeFlags.JavaScriptFile) { + if (isInJavaScriptFile(node)) { if (node.type && node.type.kind === SyntaxKind.JSDocOptionalType) { return true; } diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 04479e6f9cd29..79fd388d75be5 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -1619,7 +1619,7 @@ namespace ts { } export function isRestParameter(node: ParameterDeclaration) { - if (node && (node.flags & NodeFlags.JavaScriptFile)) { + if (isInJavaScriptFile(node)) { if (node.type && node.type.kind === SyntaxKind.JSDocVariadicType || forEach(getJSDocParameterTags(node), t => t.typeExpression && t.typeExpression.type.kind === SyntaxKind.JSDocVariadicType)) { @@ -2743,7 +2743,7 @@ namespace ts { if (node.typeParameters) { return node.typeParameters; } - if (node.flags & NodeFlags.JavaScriptFile) { + if (isInJavaScriptFile(node)) { const templateTag = getJSDocTemplateTag(node); return templateTag && templateTag.typeParameters; }