Skip to content

Commit d14685d

Browse files
committed
Fix for jsdoc modifiers on constructor params
1 parent f08863d commit d14685d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+449
-278
lines changed

src/compiler/binder.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ namespace ts {
5050
// 3. non-exported import declarations
5151
case SyntaxKind.ImportDeclaration:
5252
case SyntaxKind.ImportEqualsDeclaration:
53-
if (!(hasModifier(node, ModifierFlags.Export))) {
53+
if (!(hasSyntacticModifier(node, ModifierFlags.Export))) {
5454
return ModuleInstanceState.NonInstantiated;
5555
}
5656
break;
@@ -413,7 +413,7 @@ namespace ts {
413413
function declareSymbol(symbolTable: SymbolTable, parent: Symbol | undefined, node: Declaration, includes: SymbolFlags, excludes: SymbolFlags, isReplaceableByMethod?: boolean): Symbol {
414414
Debug.assert(!hasDynamicName(node));
415415

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

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

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

19081908
function declareClassMember(node: Declaration, symbolFlags: SymbolFlags, symbolExcludes: SymbolFlags) {
1909-
return hasModifier(node, ModifierFlags.Static)
1909+
return hasSyntacticModifier(node, ModifierFlags.Static)
19101910
? declareSymbol(container.symbol.exports!, container.symbol, node, symbolFlags, symbolExcludes)
19111911
: declareSymbol(container.symbol.members!, container.symbol, node, symbolFlags, symbolExcludes);
19121912
}
@@ -1936,7 +1936,7 @@ namespace ts {
19361936
function bindModuleDeclaration(node: ModuleDeclaration) {
19371937
setExportContextFlag(node);
19381938
if (isAmbientModule(node)) {
1939-
if (hasModifier(node, ModifierFlags.Export)) {
1939+
if (hasSyntacticModifier(node, ModifierFlags.Export)) {
19401940
errorOnFirstToken(node, Diagnostics.export_modifier_cannot_be_applied_to_ambient_modules_and_module_augmentations_since_they_are_always_visible);
19411941
}
19421942
if (isModuleAugmentationExternal(node)) {
@@ -2869,7 +2869,7 @@ namespace ts {
28692869
// this.foo assignment in a JavaScript class
28702870
// Bind this property to the containing class
28712871
const containingClass = thisContainer.parent;
2872-
const symbolTable = hasModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!;
2872+
const symbolTable = hasSyntacticModifier(thisContainer, ModifierFlags.Static) ? containingClass.symbol.exports! : containingClass.symbol.members!;
28732873
if (hasDynamicName(node)) {
28742874
bindDynamicallyNamedThisPropertyAssignment(node, containingClass.symbol);
28752875
}
@@ -3403,7 +3403,7 @@ namespace ts {
34033403
case SyntaxKind.ModuleDeclaration:
34043404
return getModuleInstanceState(s as ModuleDeclaration) !== ModuleInstanceState.Instantiated;
34053405
case SyntaxKind.EnumDeclaration:
3406-
return hasModifier(s, ModifierFlags.Const);
3406+
return hasSyntacticModifier(s, ModifierFlags.Const);
34073407
default:
34083408
return false;
34093409
}
@@ -3637,7 +3637,7 @@ namespace ts {
36373637
}
36383638

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

@@ -3676,7 +3676,7 @@ namespace ts {
36763676
function computeClassDeclaration(node: ClassDeclaration, subtreeFlags: TransformFlags) {
36773677
let transformFlags: TransformFlags;
36783678

3679-
if (hasModifier(node, ModifierFlags.Ambient)) {
3679+
if (hasSyntacticModifier(node, ModifierFlags.Ambient)) {
36803680
// An ambient declaration is TypeScript syntax.
36813681
transformFlags = TransformFlags.AssertTypeScript;
36823682
}
@@ -3767,7 +3767,7 @@ namespace ts {
37673767
let transformFlags = subtreeFlags;
37683768

37693769
// TypeScript-specific modifiers and overloads are TypeScript syntax
3770-
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
3770+
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
37713771
|| !node.body) {
37723772
transformFlags |= TransformFlags.AssertTypeScript;
37733773
}
@@ -3788,7 +3788,7 @@ namespace ts {
37883788
// Decorators, TypeScript-specific modifiers, type parameters, type annotations, and
37893789
// overloads are TypeScript syntax.
37903790
if (node.decorators
3791-
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
3791+
|| hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
37923792
|| node.typeParameters
37933793
|| node.type
37943794
|| !node.body
@@ -3802,7 +3802,7 @@ namespace ts {
38023802
}
38033803

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

@@ -3820,7 +3820,7 @@ namespace ts {
38203820
// Decorators, TypeScript-specific modifiers, type annotations, and overloads are
38213821
// TypeScript syntax.
38223822
if (node.decorators
3823-
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
3823+
|| hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
38243824
|| node.type
38253825
|| !node.body) {
38263826
transformFlags |= TransformFlags.AssertTypeScript;
@@ -3839,7 +3839,7 @@ namespace ts {
38393839
let transformFlags = subtreeFlags | TransformFlags.ContainsClassFields;
38403840

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

@@ -3854,7 +3854,7 @@ namespace ts {
38543854

38553855
function computeFunctionDeclaration(node: FunctionDeclaration, subtreeFlags: TransformFlags) {
38563856
let transformFlags: TransformFlags;
3857-
const modifierFlags = getModifierFlags(node);
3857+
const modifierFlags = getSyntacticModifierFlags(node);
38583858
const body = node.body;
38593859

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

39033903
// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
39043904
// syntax.
3905-
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
3905+
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
39063906
|| node.typeParameters
39073907
|| node.type) {
39083908
transformFlags |= TransformFlags.AssertTypeScript;
39093909
}
39103910

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

@@ -3935,14 +3935,14 @@ namespace ts {
39353935

39363936
// TypeScript-specific modifiers, type parameters, and type annotations are TypeScript
39373937
// syntax.
3938-
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
3938+
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
39393939
|| node.typeParameters
39403940
|| node.type) {
39413941
transformFlags |= TransformFlags.AssertTypeScript;
39423942
}
39433943

39443944
// An async arrow function is ES2017 syntax.
3945-
if (hasModifier(node, ModifierFlags.Async)) {
3945+
if (hasSyntacticModifier(node, ModifierFlags.Async)) {
39463946
transformFlags |= TransformFlags.AssertES2017;
39473947
}
39483948

@@ -4016,7 +4016,7 @@ namespace ts {
40164016
const declarationListTransformFlags = node.declarationList.transformFlags;
40174017

40184018
// An ambient declaration is TypeScript syntax.
4019-
if (hasModifier(node, ModifierFlags.Ambient)) {
4019+
if (hasSyntacticModifier(node, ModifierFlags.Ambient)) {
40204020
transformFlags = TransformFlags.AssertTypeScript;
40214021
}
40224022
else {
@@ -4064,7 +4064,7 @@ namespace ts {
40644064

40654065
function computeModuleDeclaration(node: ModuleDeclaration, subtreeFlags: TransformFlags) {
40664066
let transformFlags = TransformFlags.AssertTypeScript;
4067-
const modifierFlags = getModifierFlags(node);
4067+
const modifierFlags = getSyntacticModifierFlags(node);
40684068

40694069
if ((modifierFlags & ModifierFlags.Ambient) === 0) {
40704070
transformFlags |= subtreeFlags;

0 commit comments

Comments
 (0)