Skip to content

Commit d07e866

Browse files
authored
Fix for jsdoc modifiers on constructor params (#38403)
* Fix for jsdoc modifiers on constructor params * Update Public API baseline and fix unique symbol grammar check for js
1 parent 1a88430 commit d07e866

Some content is hidden

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

56 files changed

+789
-279
lines changed

src/compiler/binder.ts

+23-23
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
}
@@ -3402,7 +3402,7 @@ namespace ts {
34023402
case SyntaxKind.ModuleDeclaration:
34033403
return getModuleInstanceState(s as ModuleDeclaration) !== ModuleInstanceState.Instantiated;
34043404
case SyntaxKind.EnumDeclaration:
3405-
return hasModifier(s, ModifierFlags.Const);
3405+
return hasSyntacticModifier(s, ModifierFlags.Const);
34063406
default:
34073407
return false;
34083408
}
@@ -3636,7 +3636,7 @@ namespace ts {
36363636
}
36373637

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

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

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

37683768
// TypeScript-specific modifiers and overloads are TypeScript syntax
3769-
if (hasModifier(node, ModifierFlags.TypeScriptModifier)
3769+
if (hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
37703770
|| !node.body) {
37713771
transformFlags |= TransformFlags.AssertTypeScript;
37723772
}
@@ -3787,7 +3787,7 @@ namespace ts {
37873787
// Decorators, TypeScript-specific modifiers, type parameters, type annotations, and
37883788
// overloads are TypeScript syntax.
37893789
if (node.decorators
3790-
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
3790+
|| hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
37913791
|| node.typeParameters
37923792
|| node.type
37933793
|| !node.body
@@ -3801,7 +3801,7 @@ namespace ts {
38013801
}
38023802

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

@@ -3819,7 +3819,7 @@ namespace ts {
38193819
// Decorators, TypeScript-specific modifiers, type annotations, and overloads are
38203820
// TypeScript syntax.
38213821
if (node.decorators
3822-
|| hasModifier(node, ModifierFlags.TypeScriptModifier)
3822+
|| hasSyntacticModifier(node, ModifierFlags.TypeScriptModifier)
38233823
|| node.type
38243824
|| !node.body) {
38253825
transformFlags |= TransformFlags.AssertTypeScript;
@@ -3838,7 +3838,7 @@ namespace ts {
38383838
let transformFlags = subtreeFlags | TransformFlags.ContainsClassFields;
38393839

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

@@ -3853,7 +3853,7 @@ namespace ts {
38533853

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

38593859
if (!body || (modifierFlags & ModifierFlags.Ambient)) {
@@ -3901,14 +3901,14 @@ namespace ts {
39013901

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

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

@@ -3934,14 +3934,14 @@ namespace ts {
39343934

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

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

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

40174017
// An ambient declaration is TypeScript syntax.
4018-
if (hasModifier(node, ModifierFlags.Ambient)) {
4018+
if (hasSyntacticModifier(node, ModifierFlags.Ambient)) {
40194019
transformFlags = TransformFlags.AssertTypeScript;
40204020
}
40214021
else {
@@ -4063,7 +4063,7 @@ namespace ts {
40634063

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

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

0 commit comments

Comments
 (0)