Skip to content

Fix for jsdoc modifiers on constructor params #38403

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions src/compiler/binder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ namespace ts {
// 3. non-exported import declarations
case SyntaxKind.ImportDeclaration:
case SyntaxKind.ImportEqualsDeclaration:
if (!(hasModifier(node, ModifierFlags.Export))) {
if (!(hasSyntacticModifier(node, ModifierFlags.Export))) {
return ModuleInstanceState.NonInstantiated;
}
break;
Expand Down Expand Up @@ -413,7 +413,7 @@ namespace ts {
function declareSymbol(symbolTable: SymbolTable, parent: Symbol | undefined, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags, isReplaceableByMethod?: boolean): Symbol {
Debug.assert(!hasDynamicName(node));

const isDefaultExport = hasModifier(node, ModifierFlags.Default) || isExportSpecifier(node) && node.name.escapedText === "default";
const isDefaultExport = hasSyntacticModifier(node, ModifierFlags.Default) || isExportSpecifier(node) && node.name.escapedText === "default";

// The exported symbol for an export default function/class node is always named "default"
const name = isDefaultExport && parent ? InternalSymbolName.Default : getDeclarationName(node);
Expand Down Expand Up @@ -508,7 +508,7 @@ namespace ts {
}

const relatedInformation: DiagnosticRelatedInformation[] = [];
if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasModifier(node, ModifierFlags.Export) && symbol.flags & (SymbolFlags.Alias | SymbolFlags.Type | SymbolFlags.Namespace)) {
if (isTypeAliasDeclaration(node) && nodeIsMissing(node.type) && hasSyntacticModifier(node, ModifierFlags.Export) && symbol.flags & (SymbolFlags.Alias | SymbolFlags.Type | SymbolFlags.Namespace)) {
// export type T; - may have meant export type { T }?
relatedInformation.push(createDiagnosticForNode(node, Diagnostics.Did_you_mean_0, `export type { ${unescapeLeadingUnderscores(node.name.escapedText)} }`));
}
Expand Down Expand Up @@ -572,7 +572,7 @@ namespace ts {
// and should never be merged directly with other augmentation, and the latter case would be possible if automatic merge is allowed.
if (isJSDocTypeAlias(node)) Debug.assert(isInJSFile(node)); // We shouldn't add symbols for JSDoc nodes if not in a JS file.
if ((!isAmbientModule(node) && (hasExportModifier || container.flags & NodeFlags.ExportContext)) || isJSDocTypeAlias(node)) {
if (!container.locals || (hasModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
if (!container.locals || (hasSyntacticModifier(node, ModifierFlags.Default) && !getDeclarationName(node))) {
return declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes); // No local symbol for an unnamed default!
}
const exportKind = symbolFlags & SymbolFlags.Value ? SymbolFlags.ExportValue : 0;
Expand Down Expand Up @@ -637,7 +637,7 @@ namespace ts {
const saveExceptionTarget = currentExceptionTarget;
const saveActiveLabelList = activeLabelList;
const saveHasExplicitReturn = hasExplicitReturn;
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !hasModifier(node, ModifierFlags.Async) &&
const isIIFE = containerFlags & ContainerFlags.IsFunctionExpression && !hasSyntacticModifier(node, ModifierFlags.Async) &&
!(<FunctionLikeDeclaration>node).asteriskToken && !!getImmediatelyInvokedFunctionExpression(node);
// A non-async, non-generator IIFE is considered part of the containing control flow. Return statements behave
// similarly to break statements that exit to a label just past the statement body.
Expand Down Expand Up @@ -1906,7 +1906,7 @@ namespace ts {
}

function declareClassMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
return hasModifier(node, ModifierFlags.Static)
return hasSyntacticModifier(node, ModifierFlags.Static)
? declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes)
: declareSymbol(container.symbol.members!, container.symbol, node, symbolFlags, symbolExcludes);
}
Expand Down Expand Up @@ -1936,7 +1936,7 @@ namespace ts {
function bindModuleDeclaration(node: ModuleDeclaration) {
setExportContextFlag(node);
if (isAmbientModule(node)) {
if (hasModifier(node, ModifierFlags.Export)) {
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
}
if (isModuleAugmentationExternal(node)) {
Expand Down Expand Up @@ -2869,7 +2869,7 @@ namespace ts {
// this.foo assignment in a JavaScript class
// Bind this property to the containing class
const containingClass = thisContainer.parent;
const symbolTable = hasModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!;
const symbolTable = hasSyntacticModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!;
if (hasDynamicName(node)) {
bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol);
}
Expand Down Expand Up @@ -3403,7 +3403,7 @@ namespace ts {
case SyntaxKind.ModuleDeclaration:
return getModuleInstanceState(s as ModuleDeclaration) !== ModuleInstanceState.Instantiated;
case SyntaxKind.EnumDeclaration:
return hasModifier(s, ModifierFlags.Const);
return hasSyntacticModifier(s, ModifierFlags.Const);
default:
return false;
}
Expand Down Expand Up @@ -3637,7 +3637,7 @@ namespace ts {
}

// If a parameter has an accessibility modifier, then it is TypeScript syntax.
if (hasModifier(node, ModifierFlags.ParameterPropertyModifier)) {
if (hasSyntacticModifier(node, ModifierFlags.ParameterPropertyModifier)) {
transformFlags |= TransformFlags.AssertTypeScript | TransformFlags.ContainsTypeScriptClassSyntax;
}

Expand Down Expand Up @@ -3676,7 +3676,7 @@ namespace ts {
function computeClassDeclaration(node: ClassDeclaration, subtreeFlags: TransformFlags) {
let transformFlags: TransformFlags;

if (hasModifier(node, ModifierFlags.Ambient)) {
if (hasSyntacticModifier(node, ModifierFlags.Ambient)) {
// An ambient declaration is TypeScript syntax.
transformFlags = TransformFlags.AssertTypeScript;
}
Expand Down Expand Up @@ -3767,7 +3767,7 @@ namespace ts {
let transformFlags = subtreeFlags;

// TypeScript-specific modifiers and overloads are TypeScript syntax
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|| !node.body) {
transformFlags |= TransformFlags.AssertTypeScript;
}
Expand All @@ -3788,7 +3788,7 @@ namespace ts {
// Decorators, TypeScript-specific modifiers, type parameters, type annotations, and
// overloads are TypeScript syntax.
if (node.decorators
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
|| hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|| node.typeParameters
|| node.type
|| !node.body
Expand All @@ -3802,7 +3802,7 @@ namespace ts {
}

// An async method declaration is ES2017 syntax.
if (hasModifier(node, ModifierFlags.Async)) {
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
transformFlags |= node.asteriskToken ? TransformFlags.AssertES2018 : TransformFlags.AssertES2017;
}

Expand All @@ -3820,7 +3820,7 @@ namespace ts {
// Decorators, TypeScript-specific modifiers, type annotations, and overloads are
// TypeScript syntax.
if (node.decorators
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
|| hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|| node.type
|| !node.body) {
transformFlags |= TransformFlags.AssertTypeScript;
Expand All @@ -3839,7 +3839,7 @@ namespace ts {
let transformFlags = subtreeFlags | TransformFlags.ContainsClassFields;

// Decorators, TypeScript-specific modifiers, and type annotations are TypeScript syntax.
if (some(node.decorators) || hasModifier(node, ModifierFlags.TypeScriptModifier) || node.type || node.questionToken || node.exclamationToken) {
if (some(node.decorators) || hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier) || node.type || node.questionToken || node.exclamationToken) {
transformFlags |= TransformFlags.AssertTypeScript;
}

Expand All @@ -3854,7 +3854,7 @@ namespace ts {

function computeFunctionDeclaration(node: FunctionDeclaration, subtreeFlags: TransformFlags) {
let transformFlags: TransformFlags;
const modifierFlags = getModifierFlags(node);
const modifierFlags = getSyntacticModifierFlags(node);
const body = node.body;

if (!body || (modifierFlags & ModifierFlags.Ambient)) {
Expand Down Expand Up @@ -3902,14 +3902,14 @@ namespace ts {

// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
// syntax.
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|| node.typeParameters
|| node.type) {
transformFlags |= TransformFlags.AssertTypeScript;
}

// An async function expression is ES2017 syntax.
if (hasModifier(node, ModifierFlags.Async)) {
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
transformFlags |= node.asteriskToken ? TransformFlags.AssertES2018 : TransformFlags.AssertES2017;
}

Expand All @@ -3935,14 +3935,14 @@ namespace ts {

// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
// syntax.
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
|| node.typeParameters
|| node.type) {
transformFlags |= TransformFlags.AssertTypeScript;
}

// An async arrow function is ES2017 syntax.
if (hasModifier(node, ModifierFlags.Async)) {
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
transformFlags |= TransformFlags.AssertES2017;
}

Expand Down Expand Up @@ -4016,7 +4016,7 @@ namespace ts {
const declarationListTransformFlags = node.declarationList.transformFlags;

// An ambient declaration is TypeScript syntax.
if (hasModifier(node, ModifierFlags.Ambient)) {
if (hasSyntacticModifier(node, ModifierFlags.Ambient)) {
transformFlags = TransformFlags.AssertTypeScript;
}
else {
Expand Down Expand Up @@ -4064,7 +4064,7 @@ namespace ts {

function computeModuleDeclaration(node: ModuleDeclaration, subtreeFlags: TransformFlags) {
let transformFlags = TransformFlags.AssertTypeScript;
const modifierFlags = getModifierFlags(node);
const modifierFlags = getSyntacticModifierFlags(node);

if ((modifierFlags & ModifierFlags.Ambient) === 0) {
transformFlags |= subtreeFlags;
Expand Down
Loading