Skip to content

Commit ea48336

Browse files
committed
Drop RESERVED argument in favor of removing parameter
1 parent 39bb5e7 commit ea48336

Some content is hidden

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

59 files changed

+1734
-937
lines changed

src/compiler/checker.ts

+14-59
Large diffs are not rendered by default.

src/compiler/debug.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ namespace ts {
1919
warnAfter?: Version | string;
2020
errorAfter?: Version | string;
2121
typeScriptVersion?: Version | string;
22+
name?: string;
2223
}
2324

2425
export namespace Debug {
@@ -732,7 +733,7 @@ namespace ts {
732733
}
733734

734735
export function deprecate<F extends (...args: any[]) => any>(func: F, options?: DeprecationOptions): F {
735-
const deprecation = createDeprecation(getFunctionName(func), options);
736+
const deprecation = createDeprecation(options?.name ?? getFunctionName(func), options);
736737
return wrapFunction(deprecation, func);
737738
}
738739
}

src/compiler/factory/nodeFactory.ts

+37-150
Large diffs are not rendered by default.

src/compiler/factory/utilities.ts

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ namespace ts {
44
// Compound nodes
55

66
export function createEmptyExports(factory: NodeFactory) {
7-
return factory.createExportDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([]), /*moduleSpecifier*/ undefined);
7+
return factory.createExportDeclaration(/*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([]), /*moduleSpecifier*/ undefined);
88
}
99

1010
export function createMemberAccessForPropertyName(factory: NodeFactory, target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression {
@@ -519,7 +519,6 @@ namespace ts {
519519
}
520520
if (namedBindings) {
521521
const externalHelpersImportDeclaration = nodeFactory.createImportDeclaration(
522-
/*decorators*/ RESERVED,
523522
/*modifiers*/ undefined,
524523
nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings),
525524
nodeFactory.createStringLiteral(externalHelpersModuleNameText),

src/compiler/parser.ts

+17-24
Original file line numberDiff line numberDiff line change
@@ -3191,7 +3191,6 @@ namespace ts {
31913191
}
31923192
return finishNode(
31933193
factory.createParameterDeclaration(
3194-
/*decorators*/ RESERVED,
31953194
/*modifiers*/ undefined,
31963195
/*dotDotDotToken*/ undefined,
31973196
// TODO(rbuckton): JSDoc parameters don't have names (except `this`/`new`), should we manufacture an empty identifier?
@@ -3341,7 +3340,6 @@ namespace ts {
33413340

33423341
if (token() === SyntaxKind.ThisKeyword) {
33433342
const node = factory.createParameterDeclaration(
3344-
/*decorators*/ RESERVED,
33453343
decorators,
33463344
/*dotDotDotToken*/ undefined,
33473345
createIdentifier(/*isIdentifier*/ true),
@@ -3370,7 +3368,6 @@ namespace ts {
33703368
const node = withJSDoc(
33713369
finishNode(
33723370
factory.createParameterDeclaration(
3373-
/*decorators*/ RESERVED,
33743371
modifiers,
33753372
dotDotDotToken,
33763373
parseNameOfParameter(modifiers),
@@ -3557,7 +3554,7 @@ namespace ts {
35573554
const parameters = parseBracketedList<ParameterDeclaration>(ParsingContext.Parameters, () => parseParameter(/*inOuterAwaitContext*/ false), SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken);
35583555
const type = parseTypeAnnotation();
35593556
parseTypeMemberSemicolon();
3560-
const node = factory.createIndexSignature(/*decorators*/ RESERVED, modifiers, parameters, type);
3557+
const node = factory.createIndexSignature(modifiers, parameters, type);
35613558
node.illegalDecorators = decorators;
35623559
return withJSDoc(finishNode(node, pos), hasJSDoc);
35633560
}
@@ -4489,7 +4486,6 @@ namespace ts {
44894486
function parseSimpleArrowFunctionExpression(pos: number, identifier: Identifier, disallowReturnTypeInArrowFunction: boolean, asyncModifier?: NodeArray<Modifier> | undefined): ArrowFunction {
44904487
Debug.assert(token() === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>");
44914488
const parameter = factory.createParameterDeclaration(
4492-
/*decorators*/ RESERVED,
44934489
/*modifiers*/ undefined,
44944490
/*dotDotDotToken*/ undefined,
44954491
identifier,
@@ -6835,7 +6831,7 @@ namespace ts {
68356831
const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false);
68366832
const body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, Diagnostics.or_expected);
68376833
setAwaitContext(savedAwaitContext);
6838-
const node = factory.createFunctionDeclaration(/*decorators*/ RESERVED, modifiers, asteriskToken, name, typeParameters, parameters, type, body);
6834+
const node = factory.createFunctionDeclaration(modifiers, asteriskToken, name, typeParameters, parameters, type, body);
68396835
node.illegalDecorators = decorators;
68406836
return withJSDoc(finishNode(node, pos), hasJSDoc);
68416837
}
@@ -6859,7 +6855,7 @@ namespace ts {
68596855
const parameters = parseParameters(SignatureFlags.None);
68606856
const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false);
68616857
const body = parseFunctionBlockOrSemicolon(SignatureFlags.None, Diagnostics.or_expected);
6862-
const node = factory.createConstructorDeclaration(/*decorators*/ RESERVED, modifiers, parameters, body);
6858+
const node = factory.createConstructorDeclaration(modifiers, parameters, body);
68636859

68646860
// Attach invalid nodes if they exist so that we can report them in the grammar checker.
68656861
node.illegalDecorators = decorators;
@@ -6888,7 +6884,6 @@ namespace ts {
68886884
const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false);
68896885
const body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage);
68906886
const node = factory.createMethodDeclaration(
6891-
/*decorators*/ RESERVED,
68926887
combineDecoratorsAndModifiers(decorators, modifiers),
68936888
asteriskToken,
68946889
name,
@@ -6917,7 +6912,6 @@ namespace ts {
69176912
const initializer = doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.AwaitContext | NodeFlags.DisallowInContext, parseInitializer);
69186913
parseSemicolonAfterPropertyName(name, type, initializer);
69196914
const node = factory.createPropertyDeclaration(
6920-
/*decorators*/ RESERVED,
69216915
combineDecoratorsAndModifiers(decorators, modifiers),
69226916
name,
69236917
questionToken || exclamationToken,
@@ -6950,8 +6944,8 @@ namespace ts {
69506944
const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false);
69516945
const body = parseFunctionBlockOrSemicolon(SignatureFlags.None);
69526946
const node = kind === SyntaxKind.GetAccessor
6953-
? factory.createGetAccessorDeclaration(/*decorators*/ RESERVED, combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
6954-
: factory.createSetAccessorDeclaration(/*decorators*/ RESERVED, combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
6947+
? factory.createGetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body)
6948+
: factory.createSetAccessorDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body);
69556949
// Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors
69566950
node.illegalTypeParameters = typeParameters;
69576951
if (isSetAccessorDeclaration(node)) node.illegalType = type;
@@ -7030,7 +7024,7 @@ namespace ts {
70307024
function parseClassStaticBlockDeclaration(pos: number, hasJSDoc: boolean, decorators: NodeArray<Decorator> | undefined, modifiers: ModifiersArray | undefined): ClassStaticBlockDeclaration {
70317025
parseExpectedToken(SyntaxKind.StaticKeyword);
70327026
const body = parseClassStaticBlockBody();
7033-
const node = withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(/*decorators*/ RESERVED, RESERVED, body), pos), hasJSDoc);
7027+
const node = withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(body), pos), hasJSDoc);
70347028
node.illegalDecorators = decorators;
70357029
node.illegalModifiers = modifiers;
70367030
return node;
@@ -7236,8 +7230,8 @@ namespace ts {
72367230
}
72377231
setAwaitContext(savedAwaitContext);
72387232
const node = kind === SyntaxKind.ClassDeclaration
7239-
? factory.createClassDeclaration(/*decorators*/ RESERVED, combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members)
7240-
: factory.createClassExpression(/*decorators*/ RESERVED, combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members);
7233+
? factory.createClassDeclaration(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members)
7234+
: factory.createClassExpression(combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members);
72417235
return withJSDoc(finishNode(node, pos), hasJSDoc);
72427236
}
72437237

@@ -7305,7 +7299,7 @@ namespace ts {
73057299
const typeParameters = parseTypeParameters();
73067300
const heritageClauses = parseHeritageClauses();
73077301
const members = parseObjectTypeMembers();
7308-
const node = factory.createInterfaceDeclaration(/*decorators*/ RESERVED, modifiers, name, typeParameters, heritageClauses, members);
7302+
const node = factory.createInterfaceDeclaration(modifiers, name, typeParameters, heritageClauses, members);
73097303
node.illegalDecorators = decorators;
73107304
return withJSDoc(finishNode(node, pos), hasJSDoc);
73117305
}
@@ -7317,7 +7311,7 @@ namespace ts {
73177311
parseExpected(SyntaxKind.EqualsToken);
73187312
const type = token() === SyntaxKind.IntrinsicKeyword && tryParse(parseKeywordAndNoDot) || parseType();
73197313
parseSemicolon();
7320-
const node = factory.createTypeAliasDeclaration(/*decorators*/ RESERVED, modifiers, name, typeParameters, type);
7314+
const node = factory.createTypeAliasDeclaration(modifiers, name, typeParameters, type);
73217315
node.illegalDecorators = decorators;
73227316
return withJSDoc(finishNode(node, pos), hasJSDoc);
73237317
}
@@ -7345,7 +7339,7 @@ namespace ts {
73457339
else {
73467340
members = createMissingList<EnumMember>();
73477341
}
7348-
const node = factory.createEnumDeclaration(/*decorators*/ RESERVED, modifiers, name, members);
7342+
const node = factory.createEnumDeclaration(modifiers, name, members);
73497343
node.illegalDecorators = decorators;
73507344
return withJSDoc(finishNode(node, pos), hasJSDoc);
73517345
}
@@ -7371,7 +7365,7 @@ namespace ts {
73717365
const body = parseOptional(SyntaxKind.DotToken)
73727366
? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.NestedNamespace | namespaceFlag) as NamespaceDeclaration
73737367
: parseModuleBlock();
7374-
const node = factory.createModuleDeclaration(/*decorators*/ RESERVED, modifiers, name, body, flags);
7368+
const node = factory.createModuleDeclaration(modifiers, name, body, flags);
73757369
node.illegalDecorators = decorators;
73767370
return withJSDoc(finishNode(node, pos), hasJSDoc);
73777371
}
@@ -7395,7 +7389,7 @@ namespace ts {
73957389
else {
73967390
parseSemicolon();
73977391
}
7398-
const node = factory.createModuleDeclaration(/*decorators*/ RESERVED, modifiers, name, body, flags);
7392+
const node = factory.createModuleDeclaration(modifiers, name, body, flags);
73997393
node.illegalDecorators = decorators;
74007394
return withJSDoc(finishNode(node, pos), hasJSDoc);
74017395
}
@@ -7490,7 +7484,7 @@ namespace ts {
74907484
}
74917485

74927486
parseSemicolon();
7493-
const node = factory.createImportDeclaration(/*decorators*/ RESERVED, modifiers, importClause, moduleSpecifier, assertClause);
7487+
const node = factory.createImportDeclaration(modifiers, importClause, moduleSpecifier, assertClause);
74947488
node.illegalDecorators = decorators;
74957489
return withJSDoc(finishNode(node, pos), hasJSDoc);
74967490
}
@@ -7543,7 +7537,7 @@ namespace ts {
75437537
parseExpected(SyntaxKind.EqualsToken);
75447538
const moduleReference = parseModuleReference();
75457539
parseSemicolon();
7546-
const node = factory.createImportEqualsDeclaration(/*decorators*/ RESERVED, modifiers, isTypeOnly, identifier, moduleReference);
7540+
const node = factory.createImportEqualsDeclaration(modifiers, isTypeOnly, identifier, moduleReference);
75477541
node.illegalDecorators = decorators;
75487542
const finished = withJSDoc(finishNode(node, pos), hasJSDoc);
75497543
return finished;
@@ -7752,7 +7746,7 @@ namespace ts {
77527746
}
77537747
parseSemicolon();
77547748
setAwaitContext(savedAwaitContext);
7755-
const node = factory.createExportDeclaration(/*decorators*/ RESERVED, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause);
7749+
const node = factory.createExportDeclaration(modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause);
77567750
node.illegalDecorators = decorators;
77577751
return withJSDoc(finishNode(node, pos), hasJSDoc);
77587752
}
@@ -7770,7 +7764,7 @@ namespace ts {
77707764
const expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false);
77717765
parseSemicolon();
77727766
setAwaitContext(savedAwaitContext);
7773-
const node = factory.createExportAssignment(/*decorators*/ RESERVED, modifiers, isExportEquals, expression);
7767+
const node = factory.createExportAssignment(modifiers, isExportEquals, expression);
77747768
node.illegalDecorators = decorators;
77757769
return withJSDoc(finishNode(node, pos), hasJSDoc);
77767770
}
@@ -8621,7 +8615,6 @@ namespace ts {
86218615
if (parseOptional(SyntaxKind.DotToken)) {
86228616
const body = parseJSDocTypeNameWithNamespace(/*nested*/ true);
86238617
const jsDocNamespaceNode = factory.createModuleDeclaration(
8624-
/*decorators*/ RESERVED,
86258618
/*modifiers*/ undefined,
86268619
typeNameOrNamespaceName,
86278620
body,

src/compiler/program.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2523,7 +2523,7 @@ namespace ts {
25232523

25242524
function createSyntheticImport(text: string, file: SourceFile) {
25252525
const externalHelpersModuleReference = factory.createStringLiteral(text);
2526-
const importDecl = factory.createImportDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined);
2526+
const importDecl = factory.createImportDeclaration(/*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined);
25272527
addEmitFlags(importDecl, EmitFlags.NeverApplyImportHelper);
25282528
setParent(externalHelpersModuleReference, importDecl);
25292529
setParent(importDecl, file);

src/compiler/transformers/classFields.ts

-8
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,6 @@ namespace ts {
433433
// Initializer is elided as the field is initialized in transformConstructor.
434434
return factory.updatePropertyDeclaration(
435435
node,
436-
/*decorators*/ RESERVED,
437436
visitNodes(node.modifiers, visitor, isModifierLike),
438437
node.name,
439438
/*questionOrExclamationToken*/ undefined,
@@ -461,8 +460,6 @@ namespace ts {
461460
const initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis());
462461
if (initializerStatement) {
463462
const staticBlock = factory.createClassStaticBlockDeclaration(
464-
/*decorators*/ RESERVED,
465-
/*modifiers*/ RESERVED,
466463
factory.createBlock([initializerStatement])
467464
);
468465

@@ -1051,7 +1048,6 @@ namespace ts {
10511048
const statements: Statement[] = [
10521049
factory.updateClassDeclaration(
10531050
node,
1054-
/*decorators*/ RESERVED,
10551051
node.modifiers,
10561052
node.name,
10571053
/*typeParameters*/ undefined,
@@ -1123,7 +1119,6 @@ namespace ts {
11231119

11241120
const classExpression = factory.updateClassExpression(
11251121
node,
1126-
/*decorators*/ RESERVED,
11271122
visitNodes(node.modifiers, visitor, isModifierLike),
11281123
node.name,
11291124
/*typeParameters*/ undefined,
@@ -1208,8 +1203,6 @@ namespace ts {
12081203

12091204
if (!shouldTransformPrivateElementsOrClassStaticBlocks && some(pendingExpressions)) {
12101205
members.push(factory.createClassStaticBlockDeclaration(
1211-
/*decorators*/ RESERVED,
1212-
/*modifiers*/ RESERVED,
12131206
factory.createBlock([
12141207
factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions))
12151208
])
@@ -1265,7 +1258,6 @@ namespace ts {
12651258
setOriginalNode(
12661259
setTextRange(
12671260
factory.createConstructorDeclaration(
1268-
/*decorators*/ RESERVED,
12691261
/*modifiers*/ undefined,
12701262
parameters ?? [],
12711263
body

0 commit comments

Comments
 (0)