From 39bb5e7a41948fe92cd9d1df41e3c7706dbcc55f Mon Sep 17 00:00:00 2001 From: Ron Buckton Date: Thu, 12 May 2022 13:43:41 -0700 Subject: [PATCH] Merge 'decorators' into 'modifiers' on various Nodes --- src/compiler/binder.ts | 4 +- src/compiler/checker.ts | 264 ++-- src/compiler/commandLineParser.ts | 4 +- src/compiler/core.ts | 36 +- src/compiler/debug.ts | 10 +- src/compiler/emitter.ts | 352 +++-- src/compiler/factory/nodeFactory.ts | 771 +++++---- src/compiler/factory/nodeTests.ts | 9 + src/compiler/factory/utilities.ts | 69 +- src/compiler/parser.ts | 311 ++-- src/compiler/program.ts | 16 +- src/compiler/transformers/classFields.ts | 26 +- src/compiler/transformers/declarations.ts | 76 +- src/compiler/transformers/es2015.ts | 16 +- src/compiler/transformers/es2017.ts | 14 +- src/compiler/transformers/es2018.ts | 16 +- src/compiler/transformers/generators.ts | 6 +- src/compiler/transformers/jsx.ts | 2 +- .../transformers/module/esnextAnd2015.ts | 8 +- src/compiler/transformers/module/module.ts | 24 +- src/compiler/transformers/module/system.ts | 18 +- src/compiler/transformers/ts.ts | 66 +- src/compiler/types.ts | 324 +++- src/compiler/utilities.ts | 31 +- src/compiler/utilitiesPublic.ts | 20 +- src/compiler/visitorPublic.ts | 58 +- .../4.0/nodeFactoryTopLevelExports.ts | 1306 ++++++++++++++++ .../4.0/renamedMapInterfaces.ts | 18 + src/deprecatedCompat/4.0/renamedNodeTests.ts | 15 + .../4.2/abstractConstructorTypes.ts | 100 ++ src/deprecatedCompat/4.2/renamedNodeTests.ts | 17 + .../4.6/importTypeAssertions.ts | 96 ++ .../4.7/typeParameterModifiers.ts | 85 + .../4.8/mergeDecoratorsAndModifiers.ts | 394 +++++ src/deprecatedCompat/deprecations.ts | 1388 +---------------- src/deprecatedCompat/tsconfig.json | 10 +- src/harness/tsconfig.json | 3 +- src/services/breakpoints.ts | 23 +- src/services/callHierarchy.ts | 12 +- .../codefixes/addEmptyExportDeclaration.ts | 2 +- .../codefixes/addNameToNamelessParameter.ts | 2 +- .../codefixes/annotateWithTypeFromJSDoc.ts | 6 +- .../codefixes/convertFunctionToEs6Class.ts | 20 +- .../codefixes/convertToAsyncFunction.ts | 9 +- src/services/codefixes/convertToEsModule.ts | 6 +- .../codefixes/convertToMappedObjectType.ts | 2 +- .../codefixes/convertToTypeOnlyExport.ts | 4 +- .../codefixes/convertToTypeOnlyImport.ts | 2 +- src/services/codefixes/fixAddMissingMember.ts | 10 +- .../fixAddModuleReferTypeMissingTypeof.ts | 2 +- .../codefixes/fixInvalidImportSyntax.ts | 2 +- src/services/codefixes/fixOverrideModifier.ts | 5 +- .../codefixes/fixStrictClassInitialization.ts | 4 +- src/services/codefixes/fixUnusedIdentifier.ts | 6 +- src/services/codefixes/generateAccessors.ts | 27 +- src/services/codefixes/helpers.ts | 20 +- src/services/codefixes/importFixes.ts | 4 +- src/services/codefixes/requireInTs.ts | 4 +- src/services/codefixes/splitTypeOnlyImport.ts | 4 +- src/services/completions.ts | 6 +- src/services/formatting/formatting.ts | 12 +- src/services/formatting/rules.ts | 2 +- src/services/getEditsForFileRename.ts | 2 +- src/services/goToDefinition.ts | 2 +- src/services/importTracker.ts | 2 +- src/services/navigationBar.ts | 6 +- src/services/organizeImports.ts | 6 +- ...onvertArrowFunctionOrFunctionExpression.ts | 2 +- src/services/refactors/convertExport.ts | 4 +- src/services/refactors/convertImport.ts | 2 +- .../convertOverloadListToSingleSignature.ts | 10 +- .../convertParamsToDestructuredObject.ts | 6 +- src/services/refactors/extractSymbol.ts | 18 +- src/services/refactors/extractType.ts | 4 +- src/services/refactors/moveToNewFile.ts | 24 +- src/services/utilities.ts | 8 +- src/testRunner/tsconfig.json | 3 +- src/testRunner/unittests/factory.ts | 6 +- src/testRunner/unittests/printer.ts | 26 +- .../unittests/services/textChanges.ts | 20 +- src/testRunner/unittests/transform.ts | 40 +- src/testRunner/unittests/tsbuild/helpers.ts | 2 +- .../reference/api/tsserverlibrary.d.ts | 605 +++++-- tests/baselines/reference/api/typescript.d.ts | 605 +++++-- ...rrorOnInitializerInInterfaceProperty.types | 1 - ...itializerInObjectTypeLiteralProperty.types | 2 - .../parserConstructorDeclaration11.errors.txt | 5 +- .../parserConstructorDeclaration12.errors.txt | 26 +- ...ormsCorrectly.transformAddDecoratedNode.js | 1 - .../reference/typeGuardFunctionErrors.symbols | 2 - 90 files changed, 4827 insertions(+), 2792 deletions(-) create mode 100644 src/deprecatedCompat/4.0/nodeFactoryTopLevelExports.ts create mode 100644 src/deprecatedCompat/4.0/renamedMapInterfaces.ts create mode 100644 src/deprecatedCompat/4.0/renamedNodeTests.ts create mode 100644 src/deprecatedCompat/4.2/abstractConstructorTypes.ts create mode 100644 src/deprecatedCompat/4.2/renamedNodeTests.ts create mode 100644 src/deprecatedCompat/4.6/importTypeAssertions.ts create mode 100644 src/deprecatedCompat/4.7/typeParameterModifiers.ts create mode 100644 src/deprecatedCompat/4.8/mergeDecoratorsAndModifiers.ts diff --git a/src/compiler/binder.ts b/src/compiler/binder.ts index 66a9f6393dc75..0b737dea0a327 100644 --- a/src/compiler/binder.ts +++ b/src/compiler/binder.ts @@ -1661,8 +1661,6 @@ namespace ts { // - `BindingElement: BindingPattern Initializer?` // - https://tc39.es/ecma262/#sec-runtime-semantics-keyedbindinginitialization // - `BindingElement: BindingPattern Initializer?` - bindEach(node.decorators); - bindEach(node.modifiers); bind(node.dotDotDotToken); bind(node.propertyName); bind(node.initializer); @@ -2794,7 +2792,7 @@ namespace ts { } function bindNamespaceExportDeclaration(node: NamespaceExportDeclaration) { - if (node.modifiers && node.modifiers.length) { + if (some(node.illegalModifiers)) { file.bindDiagnostics.push(createDiagnosticForNode(node, Diagnostics.Modifiers_cannot_appear_here)); } const diag = !isSourceFile(node.parent) ? Diagnostics.Global_module_exports_may_only_appear_at_top_level diff --git a/src/compiler/checker.ts b/src/compiler/checker.ts index 4fcb0d15a5f06..1317413afa1a3 100644 --- a/src/compiler/checker.ts +++ b/src/compiler/checker.ts @@ -2348,7 +2348,7 @@ namespace ts { if (decl.kind === SyntaxKind.TypeParameter) { const parent = isJSDocTemplateTag(decl.parent) ? getJSDocHost(decl.parent) : decl.parent; if (parent === container) { - return !(isJSDocTemplateTag(decl.parent) && find((decl.parent.parent as JSDoc).tags!, isJSDocTypeAlias)); // TODO: GH#18217 + return !(isJSDocTemplateTag(decl.parent) && find((decl.parent.parent as JSDoc).tags, isJSDocTypeAlias)); } } } @@ -5505,6 +5505,7 @@ namespace ts { return factory.updateImportTypeNode( root, root.argument, + root.assertions, qualifier, typeArguments, root.isTypeOf); @@ -5770,7 +5771,7 @@ namespace ts { const indexerTypeNode = typeToTypeNodeHelper(indexInfo.keyType, context); const indexingParameter = factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name, @@ -5785,7 +5786,7 @@ namespace ts { } context.approximateLength += (name.length + 4); return factory.createIndexSignature( - /*decorators*/ undefined, + /*decorators*/ RESERVED, indexInfo.isReadonly ? [factory.createToken(SyntaxKind.ReadonlyKeyword)] : undefined, [indexingParameter], typeNode); @@ -5851,15 +5852,15 @@ namespace ts { kind === SyntaxKind.CallSignature ? factory.createCallSignature(typeParameters, parameters, returnTypeNode) : kind === SyntaxKind.ConstructSignature ? factory.createConstructSignature(typeParameters, parameters, returnTypeNode) : kind === SyntaxKind.MethodSignature ? factory.createMethodSignature(modifiers, options?.name ?? factory.createIdentifier(""), options?.questionToken, typeParameters, parameters, returnTypeNode) : - kind === SyntaxKind.MethodDeclaration ? factory.createMethodDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, options?.name ?? factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : - kind === SyntaxKind.Constructor ? factory.createConstructorDeclaration(/*decorators*/ undefined, modifiers, parameters, /*body*/ undefined) : - kind === SyntaxKind.GetAccessor ? factory.createGetAccessorDeclaration(/*decorators*/ undefined, modifiers, options?.name ?? factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : - kind === SyntaxKind.SetAccessor ? factory.createSetAccessorDeclaration(/*decorators*/ undefined, modifiers, options?.name ?? factory.createIdentifier(""), parameters, /*body*/ undefined) : - kind === SyntaxKind.IndexSignature ? factory.createIndexSignature(/*decorators*/ undefined, modifiers, parameters, returnTypeNode) : + kind === SyntaxKind.MethodDeclaration ? factory.createMethodDeclaration(/*decorators*/ RESERVED, modifiers, /*asteriskToken*/ undefined, options?.name ?? factory.createIdentifier(""), /*questionToken*/ undefined, typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === SyntaxKind.Constructor ? factory.createConstructorDeclaration(/*decorators*/ RESERVED, modifiers, parameters, /*body*/ undefined) : + kind === SyntaxKind.GetAccessor ? factory.createGetAccessorDeclaration(/*decorators*/ RESERVED, modifiers, options?.name ?? factory.createIdentifier(""), parameters, returnTypeNode, /*body*/ undefined) : + kind === SyntaxKind.SetAccessor ? factory.createSetAccessorDeclaration(/*decorators*/ RESERVED, modifiers, options?.name ?? factory.createIdentifier(""), parameters, /*body*/ undefined) : + kind === SyntaxKind.IndexSignature ? factory.createIndexSignature(/*decorators*/ RESERVED, modifiers, parameters, returnTypeNode) : kind === SyntaxKind.JSDocFunctionType ? factory.createJSDocFunctionType(parameters, returnTypeNode) : kind === SyntaxKind.FunctionType ? factory.createFunctionTypeNode(typeParameters, parameters, returnTypeNode ?? factory.createTypeReferenceNode(factory.createIdentifier(""))) : kind === SyntaxKind.ConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, returnTypeNode ?? factory.createTypeReferenceNode(factory.createIdentifier(""))) : - kind === SyntaxKind.FunctionDeclaration ? factory.createFunctionDeclaration(/*decorators*/ undefined, modifiers, /*asteriskToken*/ undefined, options?.name ? cast(options.name, isIdentifier) : factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : + kind === SyntaxKind.FunctionDeclaration ? factory.createFunctionDeclaration(/*decorators*/ RESERVED, modifiers, /*asteriskToken*/ undefined, options?.name ? cast(options.name, isIdentifier) : factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, /*body*/ undefined) : kind === SyntaxKind.FunctionExpression ? factory.createFunctionExpression(modifiers, /*asteriskToken*/ undefined, options?.name ? cast(options.name, isIdentifier) : factory.createIdentifier(""), typeParameters, parameters, returnTypeNode, factory.createBlock([])) : kind === SyntaxKind.ArrowFunction ? factory.createArrowFunction(modifiers, typeParameters, parameters, returnTypeNode, /*equalsGreaterThanToken*/ undefined, factory.createBlock([])) : Debug.assertNever(kind); @@ -5879,7 +5880,7 @@ namespace ts { const thisTag = getJSDocThisTag(signature.declaration); if (thisTag && thisTag.typeExpression) { return factory.createParameterDeclaration( - /* decorators */ undefined, + /* decorators */ RESERVED, /* modifiers */ undefined, /* dotDotDotToken */ undefined, "this", @@ -5918,7 +5919,7 @@ namespace ts { } const parameterTypeNode = serializeTypeForDeclaration(context, parameterType, parameterSymbol, context.enclosingDeclaration, privateSymbolVisitor, bundledImports); - const modifiers = !(context.flags & NodeBuilderFlags.OmitParameterModifiers) && preserveModifierFlags && parameterDeclaration && parameterDeclaration.modifiers ? parameterDeclaration.modifiers.map(factory.cloneNode) : undefined; + const modifiers = !(context.flags & NodeBuilderFlags.OmitParameterModifiers) && preserveModifierFlags && parameterDeclaration && canHaveModifiers(parameterDeclaration) ? map(getModifiers(parameterDeclaration), factory.cloneNode) : undefined; const isRest = parameterDeclaration && isRestParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & CheckFlags.RestParameter; const dotDotDotToken = isRest ? factory.createToken(SyntaxKind.DotDotDotToken) : undefined; const name = parameterDeclaration ? parameterDeclaration.name ? @@ -5930,7 +5931,7 @@ namespace ts { const isOptional = parameterDeclaration && isOptionalParameter(parameterDeclaration) || getCheckFlags(parameterSymbol) & CheckFlags.OptionalParameter; const questionToken = isOptional ? factory.createToken(SyntaxKind.QuestionToken) : undefined; const parameterNode = factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, dotDotDotToken, name, @@ -6666,10 +6667,10 @@ namespace ts { } if ((isExpressionWithTypeArguments(node) || isTypeReferenceNode(node)) && isJSDocIndexSignature(node)) { return factory.createTypeLiteralNode([factory.createIndexSignature( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, [factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotdotdotToken*/ undefined, "x", @@ -6683,10 +6684,10 @@ namespace ts { if (isJSDocConstructSignature(node)) { let newTypeNode: TypeNode | undefined; return factory.createConstructorTypeNode( - node.modifiers, + /*modifiers*/ undefined, visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), mapDefined(node.parameters, (p, i) => p.name && isIdentifier(p.name) && p.name.escapedText === "new" ? (newTypeNode = p.type, undefined) : factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), @@ -6701,7 +6702,7 @@ namespace ts { return factory.createFunctionTypeNode( visitNodes(node.typeParameters, visitExistingNodeTreeSymbols), map(node.parameters, (p, i) => factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, getEffectiveDotDotDotForParameter(p), getNameForJSDocFunctionParameter(p, i), @@ -6732,6 +6733,7 @@ namespace ts { return factory.updateImportTypeNode( node, factory.updateLiteralTypeNode(node.argument, rewriteModuleSpecifier(node, node.argument.literal)), + node.assertions, node.qualifier, visitNodes(node.typeArguments, visitExistingNodeTreeSymbols, isTypeNode), node.isTypeOf @@ -6871,13 +6873,13 @@ namespace ts { if (length(excessExports)) { ns = factory.updateModuleDeclaration( ns, - ns.decorators, + /*decorators*/ RESERVED, ns.modifiers, ns.name, body = factory.updateModuleBlock( body, factory.createNodeArray([...ns.body.statements, factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports(map(flatMap(excessExports, e => getNamesOfDeclaration(e)), id => factory.createExportSpecifier(/*isTypeOnly*/ false, /*alias*/ undefined, id))), @@ -6909,7 +6911,7 @@ namespace ts { if (length(exports) > 1) { const nonExports = filter(statements, d => !isExportDeclaration(d) || !!d.moduleSpecifier || !d.exportClause); statements = [...nonExports, factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports(flatMap(exports, e => cast(e.exportClause, isNamedExports).elements)), @@ -6927,7 +6929,7 @@ namespace ts { statements = [ ...filter(statements, s => group.indexOf(s as ExportDeclaration) === -1), factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports(flatMap(group, e => cast(e.exportClause, isNamedExports).elements)), @@ -6968,7 +6970,7 @@ namespace ts { // some items filtered, others not - update the export declaration statements[index] = factory.updateExportDeclaration( exportDecl, - exportDecl.decorators, + /*decorators*/ RESERVED, exportDecl.modifiers, exportDecl.isTypeOnly, factory.updateNamedExports( @@ -7139,7 +7141,7 @@ namespace ts { const alias = localName === propertyAccessRequire.parent.right.escapedText ? undefined : propertyAccessRequire.parent.right; addResult( factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, alias, localName)]) @@ -7177,7 +7179,7 @@ namespace ts { // To create an export named `g` that does _not_ shadow the local `g` addResult( factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, name, localName)]) @@ -7228,16 +7230,16 @@ namespace ts { for (const node of symbol.declarations) { const resolvedModule = resolveExternalModuleName(node, (node as ExportDeclaration).moduleSpecifier!); if (!resolvedModule) continue; - addResult(factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), ModifierFlags.None); + addResult(factory.createExportDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, /*exportClause*/ undefined, factory.createStringLiteral(getSpecifierForModuleSymbol(resolvedModule, context))), ModifierFlags.None); } } } if (needsPostExportDefault) { - addResult(factory.createExportAssignment(/*decorators*/ undefined, /*modifiers*/ undefined, /*isExportAssignment*/ false, factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), ModifierFlags.None); + addResult(factory.createExportAssignment(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*isExportAssignment*/ false, factory.createIdentifier(getInternalSymbolName(symbol, symbolName))), ModifierFlags.None); } else if (needsExportDeclaration) { addResult(factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, getInternalSymbolName(symbol, symbolName), symbolName)]) @@ -7311,7 +7313,7 @@ namespace ts { && serializeExistingTypeNode(context, jsdocAliasDecl.typeExpression.type, includePrivateSymbol, bundled) || typeToTypeNodeHelper(aliasType, context); addResult(setSyntheticLeadingComments( - factory.createTypeAliasDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), + factory.createTypeAliasDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, typeNode), !commentText ? [] : [{ kind: SyntaxKind.MultiLineCommentTrivia, text: "*\n * " + commentText.replace(/\n/g, "\n * ") + "\n ", pos: -1, end: -1, hasTrailingNewLine: true }] ), modifierFlags); context.flags = oldFlags; @@ -7331,7 +7333,7 @@ namespace ts { const heritageClauses = !length(baseTypes) ? undefined : [factory.createHeritageClause(SyntaxKind.ExtendsKeyword, mapDefined(baseTypes, b => trySerializeAsTypeReference(b, SymbolFlags.Value)))]; addResult(factory.createInterfaceDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, getInternalSymbolName(symbol, symbolName), typeParamDecls, @@ -7365,7 +7367,7 @@ namespace ts { const containingFile = getSourceFileOfNode(context.enclosingDeclaration); const localName = getInternalSymbolName(symbol, symbolName); const nsBody = factory.createModuleBlock([factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports(mapDefined(filter(mergedMembers, n => n.escapedName !== InternalSymbolName.ExportEquals), s => { @@ -7383,7 +7385,7 @@ namespace ts { })) )]); addResult(factory.createModuleDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createIdentifier(localName), nsBody, @@ -7394,7 +7396,7 @@ namespace ts { function serializeEnum(symbol: Symbol, symbolName: string, modifierFlags: ModifierFlags) { addResult(factory.createEnumDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, factory.createModifiersFromModifierFlags(isConstEnumSymbol(symbol) ? ModifierFlags.Const : 0), getInternalSymbolName(symbol, symbolName), map(filter(getPropertiesOfType(getTypeOfSymbol(symbol)), p => !!(p.flags & SymbolFlags.EnumMember)), p => { @@ -7462,7 +7464,7 @@ namespace ts { // Add a namespace // Create namespace as non-synthetic so it is usable as an enclosing declaration - let fakespace = parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, factory.createIdentifier(localName), factory.createModuleBlock([]), NodeFlags.Namespace); + let fakespace = parseNodeFactory.createModuleDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createIdentifier(localName), factory.createModuleBlock([]), NodeFlags.Namespace); setParent(fakespace, enclosingDeclaration as SourceFile | NamespaceDeclaration); fakespace.locals = createSymbolTable(props); fakespace.symbol = props[0].parent!; @@ -7482,7 +7484,7 @@ namespace ts { results = oldResults; // replace namespace with synthetic version const defaultReplaced = map(declarations, d => isExportAssignment(d) && !d.isExportEquals && isIdentifier(d.expression) ? factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, d.expression, factory.createIdentifier(InternalSymbolName.Default))]) @@ -7490,7 +7492,7 @@ namespace ts { const exportModifierStripped = every(defaultReplaced, d => hasSyntacticModifier(d, ModifierFlags.Export)) ? map(defaultReplaced, removeExportModifier) : defaultReplaced; fakespace = factory.updateModuleDeclaration( fakespace, - fakespace.decorators, + /*decorators*/ RESERVED, fakespace.modifiers, fakespace.name, factory.createModuleBlock(exportModifierStripped)); @@ -7574,7 +7576,7 @@ namespace ts { // Boil down all private properties into a single one. const privateProperties = hasPrivateIdentifier ? [factory.createPropertyDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createPrivateIdentifier("#private"), /*questionOrExclamationToken*/ undefined, @@ -7596,12 +7598,12 @@ namespace ts { isInJSFile(symbol.valueDeclaration) && !some(getSignaturesOfType(staticType, SignatureKind.Construct)); const constructors = isNonConstructableClassLikeInJsFile ? - [factory.createConstructorDeclaration(/*decorators*/ undefined, factory.createModifiersFromModifierFlags(ModifierFlags.Private), [], /*body*/ undefined)] : + [factory.createConstructorDeclaration(/*decorators*/ RESERVED, factory.createModifiersFromModifierFlags(ModifierFlags.Private), [], /*body*/ undefined)] : serializeSignatures(SignatureKind.Construct, staticType, staticBaseType, SyntaxKind.Constructor) as ConstructorDeclaration[]; const indexSignatures = serializeIndexSignatures(classType, baseTypes[0]); context.enclosingDeclaration = oldEnclosing; addResult(setTextRange(factory.createClassDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, localName, typeParamDecls, @@ -7658,7 +7660,7 @@ namespace ts { const specifier = getSpecifierForModuleSymbol(target.parent || target, context); // './lib' const { propertyName } = node as BindingElement; addResult(factory.createImportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, factory.createNamedImports([factory.createImportSpecifier( /*isTypeOnly*/ false, @@ -7691,7 +7693,7 @@ namespace ts { const specifier = getSpecifierForModuleSymbol(target.parent || target, context); // 'y' // import _x = require('y'); addResult(factory.createImportEqualsDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, uniqueName, @@ -7699,7 +7701,7 @@ namespace ts { ), ModifierFlags.None); // import x = _x.z addResult(factory.createImportEqualsDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createIdentifier(localName), @@ -7719,7 +7721,7 @@ namespace ts { // an external `import localName = require("whatever")` const isLocalImport = !(target.flags & SymbolFlags.ValueModule) && !isVariableDeclaration(node); addResult(factory.createImportEqualsDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createIdentifier(localName), @@ -7736,7 +7738,7 @@ namespace ts { break; case SyntaxKind.ImportClause: addResult(factory.createImportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, factory.createIdentifier(localName), /*namedBindings*/ undefined), // We use `target.parent || target` below as `target.parent` is unset when the target is a module which has been export assigned @@ -7748,7 +7750,7 @@ namespace ts { break; case SyntaxKind.NamespaceImport: addResult(factory.createImportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, /*importClause*/ undefined, factory.createNamespaceImport(factory.createIdentifier(localName))), factory.createStringLiteral(getSpecifierForModuleSymbol(target, context)), @@ -7757,7 +7759,7 @@ namespace ts { break; case SyntaxKind.NamespaceExport: addResult(factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamespaceExport(factory.createIdentifier(localName)), @@ -7766,7 +7768,7 @@ namespace ts { break; case SyntaxKind.ImportSpecifier: addResult(factory.createImportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createImportClause( /*isTypeOnly*/ false, @@ -7817,7 +7819,7 @@ namespace ts { function serializeExportSpecifier(localName: string, targetName: string, specifier?: Expression) { addResult(factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, localName !== targetName ? targetName : undefined, localName)]), @@ -7863,7 +7865,7 @@ namespace ts { context.tracker.trackSymbol = () => false; if (isExportAssignmentCompatibleSymbolName) { results.push(factory.createExportAssignment( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, isExportEquals, symbolToExpression(target, context, SymbolFlags.All) @@ -7881,7 +7883,7 @@ namespace ts { // serialize as `import _Ref = t.arg.et; export { _Ref as name }` const varName = getUnusedName(name, symbol); addResult(factory.createImportEqualsDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createIdentifier(varName), @@ -7916,7 +7918,7 @@ namespace ts { } if (isExportAssignmentCompatibleSymbolName) { results.push(factory.createExportAssignment( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, isExportEquals, factory.createIdentifier(varName) @@ -7949,7 +7951,7 @@ namespace ts { } function makeSerializePropertySymbol(createProperty: ( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | undefined, @@ -7957,7 +7959,7 @@ namespace ts { initializer: Expression | undefined ) => T, methodKind: SignatureDeclaration["kind"], useAccessors: true): (p: Symbol, isStatic: boolean, baseType: Type | undefined) => (T | AccessorDeclaration | (T | AccessorDeclaration)[]); function makeSerializePropertySymbol(createProperty: ( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | undefined, @@ -7965,7 +7967,7 @@ namespace ts { initializer: Expression | undefined ) => T, methodKind: SignatureDeclaration["kind"], useAccessors: false): (p: Symbol, isStatic: boolean, baseType: Type | undefined) => (T | T[]); function makeSerializePropertySymbol(createProperty: ( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | undefined, @@ -7994,11 +7996,11 @@ namespace ts { const result: AccessorDeclaration[] = []; if (p.flags & SymbolFlags.SetAccessor) { result.push(setTextRange(factory.createSetAccessorDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, factory.createModifiersFromModifierFlags(flag), name, [factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "arg", @@ -8011,7 +8013,7 @@ namespace ts { if (p.flags & SymbolFlags.GetAccessor) { const isPrivate = modifierFlags & ModifierFlags.Private; result.push(setTextRange(factory.createGetAccessorDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, factory.createModifiersFromModifierFlags(flag), name, [], @@ -8025,7 +8027,7 @@ namespace ts { // If this happens, we assume the accessor takes priority, as it imposes more constraints else if (p.flags & (SymbolFlags.Property | SymbolFlags.Variable | SymbolFlags.Accessor)) { return setTextRange(createProperty( - /*decorators*/ undefined, + /*decorators*/ RESERVED, factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag), name, p.flags & SymbolFlags.Optional ? factory.createToken(SyntaxKind.QuestionToken) : undefined, @@ -8040,7 +8042,7 @@ namespace ts { const signatures = getSignaturesOfType(type, SignatureKind.Call); if (flag & ModifierFlags.Private) { return setTextRange(createProperty( - /*decorators*/ undefined, + /*decorators*/ RESERVED, factory.createModifiersFromModifierFlags((isReadonlySymbol(p) ? ModifierFlags.Readonly : 0) | flag), name, p.flags & SymbolFlags.Optional ? factory.createToken(SyntaxKind.QuestionToken) : undefined, @@ -8109,7 +8111,7 @@ namespace ts { } if (privateProtected) { return [setTextRange(factory.createConstructorDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, factory.createModifiersFromModifierFlags(privateProtected), /*parameters*/ [], /*body*/ undefined, @@ -25923,7 +25925,7 @@ namespace ts { function checkThisInStaticClassFieldInitializerInDecoratedClass(thisExpression: Node, container: Node) { if (isPropertyDeclaration(container) && hasStaticModifier(container) && - container.initializer && textRangeContainsPositionInclusive(container.initializer, thisExpression.pos) && length(container.parent.decorators)) { + container.initializer && textRangeContainsPositionInclusive(container.initializer, thisExpression.pos) && hasDecorators(container.parent)) { error(thisExpression, Diagnostics.Cannot_use_this_in_a_static_property_initializer_of_a_decorated_class); } } @@ -26714,7 +26716,7 @@ namespace ts { if (decl && (isPropertyDeclaration(decl) || isPropertySignature(decl))) { const overallAnnotation = getEffectiveTypeAnnotationNode(decl); return (overallAnnotation && instantiateType(getTypeFromTypeNode(overallAnnotation), getSymbolLinks(lhsSymbol).mapper)) || - (decl.initializer && getTypeOfExpression(binaryExpression.left)); + (isPropertyDeclaration(decl) ? decl.initializer && getTypeOfExpression(binaryExpression.left) : undefined); } if (kind === AssignmentDeclarationKind.None) { return getTypeOfExpression(binaryExpression.left); @@ -31400,7 +31402,7 @@ namespace ts { const typeSymbol = exports && getSymbol(exports, JsxNames.Element, SymbolFlags.Type); const returnNode = typeSymbol && nodeBuilder.symbolToEntityName(typeSymbol, SymbolFlags.Type, node); const declaration = factory.createFunctionTypeNode(/*typeParameters*/ undefined, - [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], + [factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotdotdot*/ undefined, "props", /*questionMark*/ undefined, nodeBuilder.typeToTypeNode(result, node))], returnNode ? factory.createTypeReferenceNode(returnNode, /*typeArguments*/ undefined) : factory.createKeywordTypeNode(SyntaxKind.AnyKeyword) ); const parameterSymbol = createSymbol(SymbolFlags.FunctionScopedVariable, "props" as __String); @@ -35034,7 +35036,7 @@ namespace ts { function checkSignatureDeclaration(node: SignatureDeclaration) { // Grammar checking if (node.kind === SyntaxKind.IndexSignature) { - checkGrammarIndexSignature(node as SignatureDeclaration); + checkGrammarIndexSignature(node); } // TODO (yuisu): Remove this check in else-if when SyntaxKind.Construct is moved and ambient context is handled else if (node.kind === SyntaxKind.FunctionType || node.kind === SyntaxKind.FunctionDeclaration || node.kind === SyntaxKind.ConstructorType || @@ -35068,7 +35070,10 @@ namespace ts { forEach(node.parameters, checkParameter); // TODO(rbuckton): Should we start checking JSDoc types? - if (node.type) { + if (canHaveIllegalType(node) && node.illegalType) { + checkSourceElement(node.illegalType); + } + else if (node.type) { checkSourceElement(node.type); } @@ -36766,13 +36771,9 @@ namespace ts { /** Check the decorators of a node */ function checkDecorators(node: Node): void { - if (!node.decorators) { - return; - } - // skip this check for nodes that cannot have decorators. These should have already had an error reported by // checkGrammarDecorators. - if (!nodeCanBeDecorated(node, node.parent, node.parent.parent)) { + if (!canHaveDecorators(node) || !hasDecorators(node) || !node.modifiers || !nodeCanBeDecorated(node, node.parent, node.parent.parent)) { return; } @@ -36780,7 +36781,11 @@ namespace ts { error(node, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning); } - const firstDecorator = node.decorators[0]; + const firstDecorator = find(node.modifiers, isDecorator); + if (!firstDecorator) { + return; + } + checkExternalEmitHelpers(firstDecorator, ExternalEmitHelpers.Decorate); if (node.kind === SyntaxKind.Parameter) { checkExternalEmitHelpers(firstDecorator, ExternalEmitHelpers.Param); @@ -36792,7 +36797,7 @@ namespace ts { // we only need to perform these checks if we are emitting serialized type metadata for the target of a decorator. switch (node.kind) { case SyntaxKind.ClassDeclaration: - const constructor = getFirstConstructorWithBody(node as ClassDeclaration); + const constructor = getFirstConstructorWithBody(node); if (constructor) { for (const parameter of constructor.parameters) { markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); @@ -36803,24 +36808,24 @@ namespace ts { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: const otherKind = node.kind === SyntaxKind.GetAccessor ? SyntaxKind.SetAccessor : SyntaxKind.GetAccessor; - const otherAccessor = getDeclarationOfKind(getSymbolOfNode(node as AccessorDeclaration), otherKind); - markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node as AccessorDeclaration) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); + const otherAccessor = getDeclarationOfKind(getSymbolOfNode(node), otherKind); + markDecoratorMedataDataTypeNodeAsReferenced(getAnnotatedAccessorTypeNode(node) || otherAccessor && getAnnotatedAccessorTypeNode(otherAccessor)); break; case SyntaxKind.MethodDeclaration: - for (const parameter of (node as FunctionLikeDeclaration).parameters) { + for (const parameter of node.parameters) { markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } - markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveReturnTypeNode(node as FunctionLikeDeclaration)); + markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveReturnTypeNode(node)); break; case SyntaxKind.PropertyDeclaration: - markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveTypeAnnotationNode(node as ParameterDeclaration)); + markDecoratorMedataDataTypeNodeAsReferenced(getEffectiveTypeAnnotationNode(node)); break; case SyntaxKind.Parameter: - markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node as ParameterDeclaration)); - const containingSignature = (node as ParameterDeclaration).parent; + markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(node)); + const containingSignature = node.parent; for (const parameter of containingSignature.parameters) { markDecoratorMedataDataTypeNodeAsReferenced(getParameterTypeNodeForDecoratorCheck(parameter)); } @@ -36828,7 +36833,11 @@ namespace ts { } } - forEach(node.decorators, checkDecorator); + for (const modifier of node.modifiers) { + if (isDecorator(modifier)) { + checkDecorator(modifier); + } + } } function checkFunctionDeclaration(node: FunctionDeclaration): void { @@ -37629,7 +37638,7 @@ namespace ts { // well known symbols. if (node.name.kind === SyntaxKind.ComputedPropertyName) { checkComputedPropertyName(node.name); - if (node.initializer) { + if (hasOnlyExpressionInitializer(node) && node.initializer) { checkExpressionCached(node.initializer); } } @@ -37670,13 +37679,13 @@ namespace ts { forEach(node.name.elements, checkSourceElement); } // For a parameter declaration with an initializer, error and exit if the containing function doesn't have a body - if (node.initializer && isParameterDeclaration(node) && nodeIsMissing((getContainingFunction(node) as FunctionLikeDeclaration).body)) { + if (isParameter(node) && node.initializer && nodeIsMissing((getContainingFunction(node) as FunctionLikeDeclaration).body)) { error(node, Diagnostics.A_parameter_initializer_is_only_allowed_in_a_function_or_constructor_implementation); return; } // For a binding pattern, validate the initializer and exit if (isBindingPattern(node.name)) { - const needCheckInitializer = node.initializer && node.parent.parent.kind !== SyntaxKind.ForInStatement; + const needCheckInitializer = hasOnlyExpressionInitializer(node) && node.initializer && node.parent.parent.kind !== SyntaxKind.ForInStatement; const needCheckWidenedType = node.name.elements.length === 0; if (needCheckInitializer || needCheckWidenedType) { // Don't validate for-in initializer as it is already an error @@ -37713,7 +37722,7 @@ namespace ts { if (node === symbol.valueDeclaration) { // Node is the primary declaration of the symbol, just validate the initializer // Don't validate for-in initializer as it is already an error - const initializer = getEffectiveInitializer(node); + const initializer = hasOnlyExpressionInitializer(node) && getEffectiveInitializer(node); if (initializer) { const isJSObjectLiteralInitializer = isInJSFile(node) && isObjectLiteralExpression(initializer) && @@ -37739,7 +37748,7 @@ namespace ts { !(symbol.flags & SymbolFlags.Assignment)) { errorNextVariableOrPropertyDeclarationMustHaveSameType(symbol.valueDeclaration, type, node, declarationType); } - if (node.initializer) { + if (hasOnlyExpressionInitializer(node) && node.initializer) { checkTypeAssignableToAndOptionallyElaborate(checkExpressionCached(node.initializer), declarationType, node, node.initializer, /*headMessage*/ undefined); } if (symbol.valueDeclaration && !areDeclarationFlagsIdentical(node, symbol.valueDeclaration)) { @@ -39363,8 +39372,9 @@ namespace ts { } function checkClassDeclaration(node: ClassDeclaration) { - if (some(node.decorators) && some(node.members, p => hasStaticModifier(p) && isPrivateIdentifierClassElementDeclaration(p))) { - grammarErrorOnNode(node.decorators[0], Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); + const firstDecorator = find(node.modifiers, isDecorator); + if (firstDecorator && some(node.members, p => hasStaticModifier(p) && isPrivateIdentifierClassElementDeclaration(p))) { + grammarErrorOnNode(firstDecorator, Diagnostics.Class_decorators_can_t_be_used_with_static_private_identifier_Consider_removing_the_experimental_decorator); } if (!node.name && !hasSyntacticModifier(node, ModifierFlags.Default)) { grammarErrorOnFirstToken(node, Diagnostics.A_class_declaration_without_the_default_modifier_must_have_a_name); @@ -43336,16 +43346,19 @@ namespace ts { } // GRAMMAR CHECKING - function checkGrammarDecoratorsAndModifiers(node: Node): boolean { + function checkGrammarDecoratorsAndModifiers(node: HasModifiers | HasDecorators | HasIllegalModifiers | HasIllegalDecorators): boolean { return checkGrammarDecorators(node) || checkGrammarModifiers(node); } function checkGrammarDecorators(node: Node): boolean { - if (!node.decorators) { + if (canHaveIllegalDecorators(node) && some(node.illegalDecorators)) { + return grammarErrorOnFirstToken(node, Diagnostics.Decorators_are_not_valid_here); + } + if (!canHaveDecorators(node) || !hasDecorators(node)) { return false; } if (!nodeCanBeDecorated(node, node.parent, node.parent.parent)) { - if (node.kind === SyntaxKind.MethodDeclaration && !nodeIsPresent((node as MethodDeclaration).body)) { + if (node.kind === SyntaxKind.MethodDeclaration && !nodeIsPresent(node.body)) { return grammarErrorOnFirstToken(node, Diagnostics.A_decorator_can_only_decorate_a_method_implementation_not_an_overload); } else { @@ -43354,14 +43367,19 @@ namespace ts { } else if (node.kind === SyntaxKind.GetAccessor || node.kind === SyntaxKind.SetAccessor) { const accessors = getAllAccessorDeclarations((node.parent as ClassDeclaration).members, node as AccessorDeclaration); - if (accessors.firstAccessor.decorators && node === accessors.secondAccessor) { + if (hasDecorators(accessors.firstAccessor) && node === accessors.secondAccessor) { return grammarErrorOnFirstToken(node, Diagnostics.Decorators_cannot_be_applied_to_multiple_get_Slashset_accessors_of_the_same_name); } } return false; } - function checkGrammarModifiers(node: Node): boolean { + function checkGrammarModifiers(node: HasModifiers | HasIllegalModifiers): boolean { + if (canHaveIllegalModifiers(node)) { + const firstModifier = firstOrUndefined(node.illegalModifiers); + return !!firstModifier && grammarErrorOnNode(firstModifier, Diagnostics.Modifiers_cannot_appear_here); + } + const quickResult = reportObviousModifierErrors(node); if (quickResult !== undefined) { return quickResult; @@ -43370,6 +43388,7 @@ namespace ts { let lastStatic: Node | undefined, lastDeclare: Node | undefined, lastAsync: Node | undefined, lastOverride: Node | undefined; let flags = ModifierFlags.None; for (const modifier of node.modifiers!) { + if (isDecorator(modifier)) continue; if (modifier.kind !== SyntaxKind.ReadonlyKeyword) { if (node.kind === SyntaxKind.PropertySignature || node.kind === SyntaxKind.MethodSignature) { return grammarErrorOnNode(modifier, Diagnostics._0_modifier_cannot_appear_on_a_type_member, tokenToString(modifier.kind)); @@ -43624,10 +43643,10 @@ namespace ts { else if ((node.kind === SyntaxKind.ImportDeclaration || node.kind === SyntaxKind.ImportEqualsDeclaration) && flags & ModifierFlags.Ambient) { return grammarErrorOnNode(lastDeclare!, Diagnostics.A_0_modifier_cannot_be_used_with_an_import_declaration, "declare"); } - else if (node.kind === SyntaxKind.Parameter && (flags & ModifierFlags.ParameterPropertyModifier) && isBindingPattern((node as ParameterDeclaration).name)) { + else if (node.kind === SyntaxKind.Parameter && (flags & ModifierFlags.ParameterPropertyModifier) && isBindingPattern(node.name)) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_may_not_be_declared_using_a_binding_pattern); } - else if (node.kind === SyntaxKind.Parameter && (flags & ModifierFlags.ParameterPropertyModifier) && (node as ParameterDeclaration).dotDotDotToken) { + else if (node.kind === SyntaxKind.Parameter && (flags & ModifierFlags.ParameterPropertyModifier) && node.dotDotDotToken) { return grammarErrorOnNode(node, Diagnostics.A_parameter_property_cannot_be_declared_using_a_rest_parameter); } if (flags & ModifierFlags.Async) { @@ -43640,14 +43659,15 @@ namespace ts { * true | false: Early return this value from checkGrammarModifiers. * undefined: Need to do full checking on the modifiers. */ - function reportObviousModifierErrors(node: Node): boolean | undefined { + function reportObviousModifierErrors(node: HasModifiers): boolean | undefined { return !node.modifiers ? false : shouldReportBadModifier(node) ? grammarErrorOnFirstToken(node, Diagnostics.Modifiers_cannot_appear_here) : undefined; } - function shouldReportBadModifier(node: Node): boolean { + + function shouldReportBadModifier(node: HasModifiers): boolean { switch (node.kind) { case SyntaxKind.GetAccessor: case SyntaxKind.SetAccessor: @@ -43677,20 +43697,25 @@ namespace ts { case SyntaxKind.ClassDeclaration: case SyntaxKind.ConstructorType: return nodeHasAnyModifiersExcept(node, SyntaxKind.AbstractKeyword); + case SyntaxKind.ClassExpression: case SyntaxKind.InterfaceDeclaration: case SyntaxKind.VariableStatement: case SyntaxKind.TypeAliasDeclaration: - case SyntaxKind.ClassStaticBlockDeclaration: return true; case SyntaxKind.EnumDeclaration: return nodeHasAnyModifiersExcept(node, SyntaxKind.ConstKeyword); default: - Debug.fail(); + Debug.assertNever(node); } } } - function nodeHasAnyModifiersExcept(node: Node, allowedModifier: SyntaxKind): boolean { - return node.modifiers!.length > 1 || node.modifiers![0].kind !== allowedModifier; + + function nodeHasAnyModifiersExcept(node: HasModifiers, allowedModifier: SyntaxKind): boolean { + for (const modifier of node.modifiers!) { + if (isDecorator(modifier)) continue; + return modifier.kind !== allowedModifier; + } + return false; } function checkGrammarAsyncModifier(node: Node, asyncModifier: Node): boolean { @@ -43855,7 +43880,7 @@ namespace ts { return false; } - function checkGrammarIndexSignature(node: SignatureDeclaration) { + function checkGrammarIndexSignature(node: IndexSignatureDeclaration) { // Prevent cascading error by short-circuit return checkGrammarDecoratorsAndModifiers(node) || checkGrammarIndexSignatureParameters(node); } @@ -44025,14 +44050,20 @@ namespace ts { } // Modifiers are never allowed on properties except for 'async' on a method declaration - if (prop.modifiers) { + if (canHaveModifiers(prop) && prop.modifiers) { for (const mod of prop.modifiers) { - if (mod.kind !== SyntaxKind.AsyncKeyword || prop.kind !== SyntaxKind.MethodDeclaration) { + if (isModifier(mod) && (mod.kind !== SyntaxKind.AsyncKeyword || prop.kind !== SyntaxKind.MethodDeclaration)) { grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod)); } } } + if (canHaveIllegalModifiers(prop) && prop.illegalModifiers) { + for (const mod of prop.illegalModifiers) { + grammarErrorOnNode(mod, Diagnostics._0_modifier_cannot_be_used_here, getTextOfNode(mod)); + } + } + // ECMA-262 11.1.5 Object Initializer // If previous is not undefined then throw a SyntaxError exception if any of the following conditions are true // a.This production is contained in strict code and IsDataDescriptor(previous) is true and @@ -44044,11 +44075,11 @@ namespace ts { let currentKind: DeclarationMeaning; switch (prop.kind) { case SyntaxKind.ShorthandPropertyAssignment: - checkGrammarForInvalidExclamationToken(prop.exclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); + checkGrammarForInvalidExclamationToken(prop.illegalExclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context); // falls through case SyntaxKind.PropertyAssignment: // Grammar checking for computedPropertyName and shorthandPropertyAssignment - checkGrammarForInvalidQuestionMark(prop.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional); + checkGrammarForInvalidQuestionMark(prop.illegalQuestionToken, Diagnostics.An_object_member_cannot_be_declared_optional); if (name.kind === SyntaxKind.NumericLiteral) { checkGrammarNumericLiteral(name); } @@ -44259,7 +44290,7 @@ namespace ts { return grammarErrorOnNode(accessor.body, Diagnostics.An_implementation_cannot_be_declared_in_ambient_contexts); } } - if (accessor.typeParameters) { + if (accessor.illegalTypeParameters) { return grammarErrorOnNode(accessor.name, Diagnostics.An_accessor_cannot_have_type_parameters); } if (!doesAccessorHaveCorrectParameterCount(accessor)) { @@ -44269,7 +44300,7 @@ namespace ts { Diagnostics.A_set_accessor_must_have_exactly_one_parameter); } if (accessor.kind === SyntaxKind.SetAccessor) { - if (accessor.type) { + if (accessor.illegalType) { return grammarErrorOnNode(accessor.name, Diagnostics.A_set_accessor_cannot_have_a_return_type_annotation); } const parameter = Debug.checkDefined(getSetAccessorValueParameter(accessor), "Return value does not match parameter count assertion."); @@ -44370,7 +44401,7 @@ namespace ts { else if (checkGrammarForInvalidQuestionMark(node.questionToken, Diagnostics.An_object_member_cannot_be_declared_optional)) { return true; } - else if (checkGrammarForInvalidExclamationToken(node.exclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) { + else if (checkGrammarForInvalidExclamationToken(node.illegalExclamationToken, Diagnostics.A_definite_assignment_assertion_is_not_permitted_in_this_context)) { return true; } else if (node.body === undefined) { @@ -44499,7 +44530,7 @@ namespace ts { } function checkAmbientInitializer(node: VariableDeclaration | PropertyDeclaration | PropertySignature) { - const {initializer} = node; + const initializer = hasOnlyExpressionInitializer(node) ? node.initializer : node.illegalInitializer; if (initializer) { const isInvalidInitializer = !( isStringOrNumberLiteralExpression(initializer) || @@ -44696,7 +44727,7 @@ namespace ts { function checkGrammarConstructorTypeParameters(node: ConstructorDeclaration) { const jsdocTypeParameters = isInJSFile(node) ? getJSDocTypeParameterDeclarations(node) : undefined; - const range = node.typeParameters || jsdocTypeParameters && firstOrUndefined(jsdocTypeParameters); + const range = node.illegalTypeParameters || jsdocTypeParameters && firstOrUndefined(jsdocTypeParameters); if (range) { const pos = range.pos === range.end ? range.pos : skipTrivia(getSourceFileOfNode(node).text, range.pos); return grammarErrorAtPos(node, pos, range.end - pos, Diagnostics.Type_parameters_cannot_appear_on_a_constructor_declaration); @@ -44704,7 +44735,7 @@ namespace ts { } function checkGrammarConstructorTypeAnnotation(node: ConstructorDeclaration) { - const type = getEffectiveReturnTypeNode(node); + const type = node.illegalType || getEffectiveReturnTypeNode(node); if (type) { return grammarErrorOnNode(type, Diagnostics.Type_annotation_cannot_appear_on_a_constructor_declaration); } @@ -44731,16 +44762,21 @@ namespace ts { if (checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_an_interface_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } - if (node.initializer) { - return grammarErrorOnNode(node.initializer, Diagnostics.An_interface_property_cannot_have_an_initializer); + + // Interfaces cannot contain property declarations + Debug.assertNode(node, isPropertySignature); + if (node.illegalInitializer) { + return grammarErrorOnNode(node.illegalInitializer, Diagnostics.An_interface_property_cannot_have_an_initializer); } } else if (isTypeLiteralNode(node.parent)) { if (checkGrammarForInvalidDynamicName(node.name, Diagnostics.A_computed_property_name_in_a_type_literal_must_refer_to_an_expression_whose_type_is_a_literal_type_or_a_unique_symbol_type)) { return true; } - if (node.initializer) { - return grammarErrorOnNode(node.initializer, Diagnostics.A_type_literal_property_cannot_have_an_initializer); + // Type literals cannot contain property declarations + Debug.assertNode(node, isPropertySignature); + if (node.illegalInitializer) { + return grammarErrorOnNode(node.illegalInitializer, Diagnostics.A_type_literal_property_cannot_have_an_initializer); } } diff --git a/src/compiler/commandLineParser.ts b/src/compiler/commandLineParser.ts index 6ed23d16e6b5a..0dff18164c924 100644 --- a/src/compiler/commandLineParser.ts +++ b/src/compiler/commandLineParser.ts @@ -2057,8 +2057,8 @@ namespace ts { continue; } - if (element.questionToken) { - errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.questionToken, Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); + if (element.illegalQuestionToken) { + errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.illegalQuestionToken, Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, "?")); } if (!isDoubleQuotedString(element.name)) { errors.push(createDiagnosticForNodeInSourceFile(sourceFile, element.name, Diagnostics.String_literal_with_double_quotes_expected)); diff --git a/src/compiler/core.ts b/src/compiler/core.ts index a3be6f976cdc9..a4c474f2ac9a4 100644 --- a/src/compiler/core.ts +++ b/src/compiler/core.ts @@ -163,10 +163,11 @@ namespace ts { } /** Works like Array.prototype.find, returning `undefined` if no element satisfying the predicate is found. */ - export function find(array: readonly T[], predicate: (element: T, index: number) => element is U): U | undefined; - export function find(array: readonly T[], predicate: (element: T, index: number) => boolean): T | undefined; - export function find(array: readonly T[], predicate: (element: T, index: number) => boolean): T | undefined { - for (let i = 0; i < array.length; i++) { + export function find(array: readonly T[] | undefined, predicate: (element: T, index: number) => element is U, startIndex?: number): U | undefined; + export function find(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): T | undefined; + export function find(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): T | undefined { + if (array === undefined) return undefined; + for (let i = startIndex ?? 0; i < array.length; i++) { const value = array[i]; if (predicate(value, i)) { return value; @@ -175,10 +176,11 @@ namespace ts { return undefined; } - export function findLast(array: readonly T[], predicate: (element: T, index: number) => element is U): U | undefined; - export function findLast(array: readonly T[], predicate: (element: T, index: number) => boolean): T | undefined; - export function findLast(array: readonly T[], predicate: (element: T, index: number) => boolean): T | undefined { - for (let i = array.length - 1; i >= 0; i--) { + export function findLast(array: readonly T[] | undefined, predicate: (element: T, index: number) => element is U, startIndex?: number): U | undefined; + export function findLast(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): T | undefined; + export function findLast(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): T | undefined { + if (array === undefined) return undefined; + for (let i = startIndex ?? array.length - 1; i >= 0; i--) { const value = array[i]; if (predicate(value, i)) { return value; @@ -188,8 +190,9 @@ namespace ts { } /** Works like Array.prototype.findIndex, returning `-1` if no element satisfying the predicate is found. */ - export function findIndex(array: readonly T[], predicate: (element: T, index: number) => boolean, startIndex?: number): number { - for (let i = startIndex || 0; i < array.length; i++) { + export function findIndex(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): number { + if (array === undefined) return -1; + for (let i = startIndex ?? 0; i < array.length; i++) { if (predicate(array[i], i)) { return i; } @@ -197,8 +200,9 @@ namespace ts { return -1; } - export function findLastIndex(array: readonly T[], predicate: (element: T, index: number) => boolean, startIndex?: number): number { - for (let i = startIndex === undefined ? array.length - 1 : startIndex; i >= 0; i--) { + export function findLastIndex(array: readonly T[] | undefined, predicate: (element: T, index: number) => boolean, startIndex?: number): number { + if (array === undefined) return -1; + for (let i = startIndex ?? array.length - 1; i >= 0; i--) { if (predicate(array[i], i)) { return i; } @@ -1079,8 +1083,8 @@ namespace ts { /** * Returns the first element of an array if non-empty, `undefined` otherwise. */ - export function firstOrUndefined(array: readonly T[]): T | undefined { - return array.length === 0 ? undefined : array[0]; + export function firstOrUndefined(array: readonly T[] | undefined): T | undefined { + return array === undefined || array.length === 0 ? undefined : array[0]; } export function first(array: readonly T[]): T { @@ -1091,8 +1095,8 @@ namespace ts { /** * Returns the last element of an array if non-empty, `undefined` otherwise. */ - export function lastOrUndefined(array: readonly T[]): T | undefined { - return array.length === 0 ? undefined : array[array.length - 1]; + export function lastOrUndefined(array: readonly T[] | undefined): T | undefined { + return array === undefined || array.length === 0 ? undefined : array[array.length - 1]; } export function last(array: readonly T[]): T { diff --git a/src/compiler/debug.ts b/src/compiler/debug.ts index 8ab5de5b77832..b6a61f2465514 100644 --- a/src/compiler/debug.ts +++ b/src/compiler/debug.ts @@ -191,8 +191,10 @@ namespace ts { export function assertEachNode(nodes: NodeArray, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray; export function assertEachNode(nodes: readonly T[], test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[]; + export function assertEachNode(nodes: NodeArray | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is NodeArray | undefined; + export function assertEachNode(nodes: readonly T[] | undefined, test: (node: T) => node is U, message?: string, stackCrawlMark?: AnyFunction): asserts nodes is readonly U[] | undefined; export function assertEachNode(nodes: readonly Node[], test: (node: Node) => boolean, message?: string, stackCrawlMark?: AnyFunction): void; - export function assertEachNode(nodes: readonly Node[], test: (node: Node) => boolean, message?: string, stackCrawlMark?: AnyFunction) { + export function assertEachNode(nodes: readonly Node[] | undefined, test: (node: Node) => boolean, message?: string, stackCrawlMark?: AnyFunction) { if (shouldAssertFunction(AssertionLevel.Normal, "assertEachNode")) { assert( test === undefined || every(nodes, test), @@ -708,9 +710,9 @@ namespace ts { }; } - function createDeprecation(name: string, options: DeprecationOptions & { error: true }): () => never; - function createDeprecation(name: string, options?: DeprecationOptions): () => void; - function createDeprecation(name: string, options: DeprecationOptions = {}) { + export function createDeprecation(name: string, options: DeprecationOptions & { error: true }): () => never; + export function createDeprecation(name: string, options?: DeprecationOptions): () => void; + export function createDeprecation(name: string, options: DeprecationOptions = {}) { const version = typeof options.typeScriptVersion === "string" ? new Version(options.typeScriptVersion) : options.typeScriptVersion ?? getTypeScriptVersion(); const errorAfter = typeof options.errorAfter === "string" ? new Version(options.errorAfter) : options.errorAfter; const warnAfter = typeof options.warnAfter === "string" ? new Version(options.warnAfter) : options.warnAfter; diff --git a/src/compiler/emitter.ts b/src/compiler/emitter.ts index c83713750f2a6..3ce5f905a6f97 100644 --- a/src/compiler/emitter.ts +++ b/src/compiler/emitter.ts @@ -2031,8 +2031,7 @@ namespace ts { } function emitParameter(node: ParameterDeclaration) { - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + emitDecoratorsAndModifiers(node, node.modifiers); emit(node.dotDotDotToken); emitNodeWithWriter(node.name, writeParameter); emit(node.questionToken); @@ -2043,7 +2042,7 @@ namespace ts { emitTypeAnnotation(node.type); } // The comment position has to fallback to any present node within the parameterdeclaration because as it turns out, the parser can make parameter declarations with _just_ an initializer. - emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.decorators ? node.decorators.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); + emitInitializer(node.initializer, node.type ? node.type.end : node.questionToken ? node.questionToken.end : node.name ? node.name.end : node.modifiers ? node.modifiers.end : node.pos, node, parenthesizer.parenthesizeExpressionForDisallowedComma); } function emitDecorator(decorator: Decorator) { @@ -2056,7 +2055,6 @@ namespace ts { // function emitPropertySignature(node: PropertySignature) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emitNodeWithWriter(node.name, writeProperty); emit(node.questionToken); @@ -2065,8 +2063,7 @@ namespace ts { } function emitPropertyDeclaration(node: PropertyDeclaration) { - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + emitDecoratorsAndModifiers(node, node.modifiers); emit(node.name); emit(node.questionToken); emit(node.exclamationToken); @@ -2077,7 +2074,6 @@ namespace ts { function emitMethodSignature(node: MethodSignature) { pushNameGenerationScope(node); - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emit(node.name); emit(node.questionToken); @@ -2089,8 +2085,7 @@ namespace ts { } function emitMethodDeclaration(node: MethodDeclaration) { - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + emitDecoratorsAndModifiers(node, node.modifiers); emit(node.asteriskToken); emit(node.name); emit(node.questionToken); @@ -2098,8 +2093,6 @@ namespace ts { } function emitClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration) { - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); writeKeyword("static"); emitBlockFunctionBody(node.body); } @@ -2111,8 +2104,7 @@ namespace ts { } function emitAccessorDeclaration(node: AccessorDeclaration) { - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + emitDecoratorsAndModifiers(node, node.modifiers); writeKeyword(node.kind === SyntaxKind.GetAccessor ? "get" : "set"); writeSpace(); emit(node.name); @@ -2121,8 +2113,6 @@ namespace ts { function emitCallSignature(node: CallSignatureDeclaration) { pushNameGenerationScope(node); - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); emitTypeParameters(node, node.typeParameters); emitParameters(node, node.parameters); emitTypeAnnotation(node.type); @@ -2132,8 +2122,6 @@ namespace ts { function emitConstructSignature(node: ConstructSignatureDeclaration) { pushNameGenerationScope(node); - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); writeKeyword("new"); writeSpace(); emitTypeParameters(node, node.typeParameters); @@ -2144,7 +2132,6 @@ namespace ts { } function emitIndexSignature(node: IndexSignatureDeclaration) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emitParametersForIndexSignature(node, node.parameters); emitTypeAnnotation(node.type); @@ -2596,7 +2583,6 @@ namespace ts { } function emitArrowFunction(node: ArrowFunction) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); emitSignatureAndBody(node, emitArrowFunctionHead); } @@ -3143,7 +3129,6 @@ namespace ts { } function emitFunctionDeclarationOrExpression(node: FunctionDeclaration | FunctionExpression) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); writeKeyword("function"); emit(node.asteriskToken); @@ -3213,8 +3198,8 @@ namespace ts { return false; } - if (getLeadingLineTerminatorCount(body, body.statements, ListFormat.PreserveLines) - || getClosingLineTerminatorCount(body, body.statements, ListFormat.PreserveLines)) { + if (getLeadingLineTerminatorCount(body, firstOrUndefined(body.statements), ListFormat.PreserveLines) + || getClosingLineTerminatorCount(body, lastOrUndefined(body.statements), ListFormat.PreserveLines, body.statements)) { return false; } @@ -3273,8 +3258,7 @@ namespace ts { function emitClassDeclarationOrExpression(node: ClassDeclaration | ClassExpression) { forEach(node.members, generateMemberNames); - emitDecorators(node, node.decorators); - emitModifiers(node, node.modifiers); + emitDecoratorsAndModifiers(node, node.modifiers); writeKeyword("class"); if (node.name) { writeSpace(); @@ -3300,7 +3284,6 @@ namespace ts { } function emitInterfaceDeclaration(node: InterfaceDeclaration) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); writeKeyword("interface"); writeSpace(); @@ -3314,7 +3297,6 @@ namespace ts { } function emitTypeAliasDeclaration(node: TypeAliasDeclaration) { - emitDecorators(node, node.decorators); emitModifiers(node, node.modifiers); writeKeyword("type"); writeSpace(); @@ -4184,13 +4166,68 @@ namespace ts { write = savedWrite; } - function emitModifiers(node: Node, modifiers: NodeArray | undefined) { - if (modifiers && modifiers.length) { - emitList(node, modifiers, ListFormat.Modifiers); - writeSpace(); + function emitDecoratorsAndModifiers(node: Node, modifiers: NodeArray | undefined) { + if (modifiers?.length) { + if (every(modifiers, isModifier)) { + // if all modifier-likes are `Modifier`, simply emit the array as modifiers. + return emitModifiers(node, modifiers as NodeArray); + } + + if (every(modifiers, isDecorator)) { + // if all modifier-likes are `Decorator`, simply emit the array as decorators. + return emitDecorators(node, modifiers as NodeArray); + } + + onBeforeEmitNodeArray?.(modifiers); + + // partition modifiers into contiguous chunks of `Modifier` or `Decorator` + let lastMode: "modifiers" | "decorators" | undefined; + let mode: "modifiers" | "decorators" | undefined; + let start = 0; + let pos = 0; + while (start < modifiers.length) { + while (pos < modifiers.length) { + const modifier = modifiers[pos]; + mode = isDecorator(modifier) ? "decorators" : "modifiers"; + if (lastMode === undefined) { + lastMode = mode; + } + else if (mode !== lastMode) { + break; + } + + pos++; + } + + if (start < pos) { + const textRange: TextRange = { pos: -1, end: -1 }; + if (start === 0) textRange.pos = modifiers.pos; + if (pos === modifiers.length - 1) textRange.end = modifiers.end; + emitNodeListItems( + emit, + node, + modifiers, + lastMode === "modifiers" ? ListFormat.Modifiers : ListFormat.Decorators, + /*parenthesizerRule*/ undefined, + start, + pos - start, + /*hasTrailingComma*/ false, + textRange); + start = pos; + } + + lastMode = mode; + pos++; + } + + onAfterEmitNodeArray?.(modifiers); } } + function emitModifiers(node: Node, modifiers: NodeArray | undefined): void { + emitList(node, modifiers, ListFormat.Modifiers); + } + function emitTypeAnnotation(node: TypeNode | undefined) { if (node) { writePunctuation(":"); @@ -4254,7 +4291,7 @@ namespace ts { } } - function emitDecorators(parentNode: Node, decorators: NodeArray | undefined) { + function emitDecorators(parentNode: Node, decorators: NodeArray | undefined): void { emitList(parentNode, decorators, ListFormat.Decorators); } @@ -4279,11 +4316,9 @@ namespace ts { && parameter.pos === parentNode.pos // may not have parsed tokens between parent and parameter && isArrowFunction(parentNode) // only arrow functions may have simple arrow head && !parentNode.type // arrow function may not have return type annotation - && !some(parentNode.decorators) // parent may not have decorators - && !some(parentNode.modifiers) // parent may not have modifiers + && !some(parentNode.modifiers) // parent may not have decorators or modifiers && !some(parentNode.typeParameters) // parent may not have type parameters - && !some(parameter.decorators) // parameter may not have decorators - && !some(parameter.modifiers) // parameter may not have modifiers + && !some(parameter.modifiers) // parameter may not have decorators or modifiers && !parameter.dotDotDotToken // parameter may not be rest && !parameter.questionToken // parameter may not be optional && !parameter.type // parameter may not have a type annotation @@ -4343,12 +4378,8 @@ namespace ts { const isEmpty = children === undefined || start >= children.length || count === 0; if (isEmpty && format & ListFormat.OptionalIfEmpty) { - if (onBeforeEmitNodeArray) { - onBeforeEmitNodeArray(children); - } - if (onAfterEmitNodeArray) { - onAfterEmitNodeArray(children); - } + onBeforeEmitNodeArray?.(children); + onAfterEmitNodeArray?.(children); return; } @@ -4359,9 +4390,7 @@ namespace ts { } } - if (onBeforeEmitNodeArray) { - onBeforeEmitNodeArray(children); - } + onBeforeEmitNodeArray?.(children); if (isEmpty) { // Write a line terminator if the parent node was multi-line @@ -4373,140 +4402,147 @@ namespace ts { } } else { - Debug.type>(children); - // Write the opening line terminator or leading whitespace. - const mayEmitInterveningComments = (format & ListFormat.NoInterveningComments) === 0; - let shouldEmitInterveningComments = mayEmitInterveningComments; - const leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children, format); // TODO: GH#18217 - if (leadingLineTerminatorCount) { - writeLine(leadingLineTerminatorCount); - shouldEmitInterveningComments = false; - } - else if (format & ListFormat.SpaceBetweenBraces) { - writeSpace(); - } - - // Increase the indent, if requested. - if (format & ListFormat.Indented) { - increaseIndent(); - } + emitNodeListItems(emit, parentNode, children, format, parenthesizerRule, start, count, children.hasTrailingComma, children); + } - const emitListItem = getEmitListItem(emit, parenthesizerRule); + onAfterEmitNodeArray?.(children); - // Emit each child. - let previousSibling: Node | undefined; - let previousSourceFileTextKind: ReturnType; - let shouldDecreaseIndentAfterEmit = false; - for (let i = 0; i < count; i++) { - const child = children[start + i]; + if (format & ListFormat.BracketsMask) { + if (isEmpty && children) { + emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists + } + writePunctuation(getClosingBracket(format)); + } + } - // Write the delimiter if this is not the first node. - if (format & ListFormat.AsteriskDelimited) { - // always write JSDoc in the format "\n *" - writeLine(); - writeDelimiter(format); - } - else if (previousSibling) { - // i.e - // function commentedParameters( - // /* Parameter a */ - // a - // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline - // , - if (format & ListFormat.DelimitersMask && previousSibling.end !== (parentNode ? parentNode.end : -1)) { - emitLeadingCommentsOfPosition(previousSibling.end); - } - writeDelimiter(format); - recordBundleFileInternalSectionEnd(previousSourceFileTextKind); - - // Write either a line terminator or whitespace to separate the elements. - const separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format); - if (separatingLineTerminatorCount > 0) { - // If a synthesized node in a single-line list starts on a new - // line, we should increase the indent. - if ((format & (ListFormat.LinesMask | ListFormat.Indented)) === ListFormat.SingleLine) { - increaseIndent(); - shouldDecreaseIndentAfterEmit = true; - } + /** + * Emits a list without brackets or raising events. + * + * NOTE: You probably don't want to call this directly and should be using `emitList` or `emitExpressionList` instead. + */ + function emitNodeListItems(emit: (node: Node, parenthesizerRule?: ((node: Node) => Node) | undefined) => void, parentNode: Node | undefined, children: readonly Node[], format: ListFormat, parenthesizerRule: ParenthesizerRuleOrSelector | undefined, start: number, count: number, hasTrailingComma: boolean, childrenTextRange: TextRange | undefined) { + // Write the opening line terminator or leading whitespace. + const mayEmitInterveningComments = (format & ListFormat.NoInterveningComments) === 0; + let shouldEmitInterveningComments = mayEmitInterveningComments; - writeLine(separatingLineTerminatorCount); - shouldEmitInterveningComments = false; - } - else if (previousSibling && format & ListFormat.SpaceBetweenSiblings) { - writeSpace(); - } - } + const leadingLineTerminatorCount = getLeadingLineTerminatorCount(parentNode, children[start], format); + if (leadingLineTerminatorCount) { + writeLine(leadingLineTerminatorCount); + shouldEmitInterveningComments = false; + } + else if (format & ListFormat.SpaceBetweenBraces) { + writeSpace(); + } - // Emit this child. - previousSourceFileTextKind = recordBundleFileInternalSectionStart(child); - if (shouldEmitInterveningComments) { - const commentRange = getCommentRange(child); - emitTrailingCommentsOfPosition(commentRange.pos); - } - else { - shouldEmitInterveningComments = mayEmitInterveningComments; - } + // Increase the indent, if requested. + if (format & ListFormat.Indented) { + increaseIndent(); + } - nextListElementPos = child.pos; - emitListItem(child, emit, parenthesizerRule, i); + const emitListItem = getEmitListItem(emit, parenthesizerRule); - if (shouldDecreaseIndentAfterEmit) { - decreaseIndent(); - shouldDecreaseIndentAfterEmit = false; - } + // Emit each child. + let previousSibling: Node | undefined; + let previousSourceFileTextKind: ReturnType; + let shouldDecreaseIndentAfterEmit = false; + for (let i = 0; i < count; i++) { + const child = children[start + i]; - previousSibling = child; + // Write the delimiter if this is not the first node. + if (format & ListFormat.AsteriskDelimited) { + // always write JSDoc in the format "\n *" + writeLine(); + writeDelimiter(format); } + else if (previousSibling) { + // i.e + // function commentedParameters( + // /* Parameter a */ + // a + // /* End of parameter a */ -> this comment isn't considered to be trailing comment of parameter "a" due to newline + // , + if (format & ListFormat.DelimitersMask && previousSibling.end !== (parentNode ? parentNode.end : -1)) { + emitLeadingCommentsOfPosition(previousSibling.end); + } + writeDelimiter(format); + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); + + // Write either a line terminator or whitespace to separate the elements. + const separatingLineTerminatorCount = getSeparatingLineTerminatorCount(previousSibling, child, format); + if (separatingLineTerminatorCount > 0) { + // If a synthesized node in a single-line list starts on a new + // line, we should increase the indent. + if ((format & (ListFormat.LinesMask | ListFormat.Indented)) === ListFormat.SingleLine) { + increaseIndent(); + shouldDecreaseIndentAfterEmit = true; + } - // Write a trailing comma, if requested. - const emitFlags = previousSibling ? getEmitFlags(previousSibling) : 0; - const skipTrailingComments = commentsDisabled || !!(emitFlags & EmitFlags.NoTrailingComments); - const hasTrailingComma = children?.hasTrailingComma && (format & ListFormat.AllowTrailingComma) && (format & ListFormat.CommaDelimited); - if (hasTrailingComma) { - if (previousSibling && !skipTrailingComments) { - emitTokenWithComment(SyntaxKind.CommaToken, previousSibling.end, writePunctuation, previousSibling); + writeLine(separatingLineTerminatorCount); + shouldEmitInterveningComments = false; } - else { - writePunctuation(","); + else if (previousSibling && format & ListFormat.SpaceBetweenSiblings) { + writeSpace(); } } - // Emit any trailing comment of the last element in the list - // i.e - // var array = [... - // 2 - // /* end of element 2 */ - // ]; - if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & ListFormat.DelimitersMask) && !skipTrailingComments) { - emitLeadingCommentsOfPosition(hasTrailingComma && children?.end ? children.end : previousSibling.end); + // Emit this child. + previousSourceFileTextKind = recordBundleFileInternalSectionStart(child); + if (shouldEmitInterveningComments) { + const commentRange = getCommentRange(child); + emitTrailingCommentsOfPosition(commentRange.pos); } + else { + shouldEmitInterveningComments = mayEmitInterveningComments; + } + + nextListElementPos = child.pos; + emitListItem(child, emit, parenthesizerRule, i); - // Decrease the indent, if requested. - if (format & ListFormat.Indented) { + if (shouldDecreaseIndentAfterEmit) { decreaseIndent(); + shouldDecreaseIndentAfterEmit = false; } - recordBundleFileInternalSectionEnd(previousSourceFileTextKind); + previousSibling = child; + } - // Write the closing line terminator or closing whitespace. - const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children, format); - if (closingLineTerminatorCount) { - writeLine(closingLineTerminatorCount); + // Write a trailing comma, if requested. + const emitFlags = previousSibling ? getEmitFlags(previousSibling) : 0; + const skipTrailingComments = commentsDisabled || !!(emitFlags & EmitFlags.NoTrailingComments); + const emitTrailingComma = hasTrailingComma && (format & ListFormat.AllowTrailingComma) && (format & ListFormat.CommaDelimited); + if (emitTrailingComma) { + if (previousSibling && !skipTrailingComments) { + emitTokenWithComment(SyntaxKind.CommaToken, previousSibling.end, writePunctuation, previousSibling); } - else if (format & (ListFormat.SpaceAfterList | ListFormat.SpaceBetweenBraces)) { - writeSpace(); + else { + writePunctuation(","); } } - if (onAfterEmitNodeArray) { - onAfterEmitNodeArray(children); + // Emit any trailing comment of the last element in the list + // i.e + // var array = [... + // 2 + // /* end of element 2 */ + // ]; + if (previousSibling && (parentNode ? parentNode.end : -1) !== previousSibling.end && (format & ListFormat.DelimitersMask) && !skipTrailingComments) { + emitLeadingCommentsOfPosition(emitTrailingComma && childrenTextRange?.end ? childrenTextRange.end : previousSibling.end); } - if (format & ListFormat.BracketsMask) { - if (isEmpty && children) { - emitLeadingCommentsOfPosition(children.end); // Emit leading comments within empty lists - } - writePunctuation(getClosingBracket(format)); + // Decrease the indent, if requested. + if (format & ListFormat.Indented) { + decreaseIndent(); + } + + recordBundleFileInternalSectionEnd(previousSourceFileTextKind); + + // Write the closing line terminator or closing whitespace. + const closingLineTerminatorCount = getClosingLineTerminatorCount(parentNode, children[start + count - 1], format, childrenTextRange); + if (closingLineTerminatorCount) { + writeLine(closingLineTerminatorCount); + } + else if (format & (ListFormat.SpaceAfterList | ListFormat.SpaceBetweenBraces)) { + writeSpace(); } } @@ -4661,13 +4697,12 @@ namespace ts { } } - function getLeadingLineTerminatorCount(parentNode: Node | undefined, children: readonly Node[], format: ListFormat): number { + function getLeadingLineTerminatorCount(parentNode: Node | undefined, firstChild: Node | undefined, format: ListFormat): number { if (format & ListFormat.PreserveLines || preserveSourceNewlines) { if (format & ListFormat.PreferNewLine) { return 1; } - const firstChild = children[0]; if (firstChild === undefined) { return !parentNode || currentSourceFile && rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } @@ -4755,19 +4790,18 @@ namespace ts { return format & ListFormat.MultiLine ? 1 : 0; } - function getClosingLineTerminatorCount(parentNode: Node | undefined, children: readonly Node[], format: ListFormat): number { + function getClosingLineTerminatorCount(parentNode: Node | undefined, lastChild: Node | undefined, format: ListFormat, childrenTextRange: TextRange | undefined): number { if (format & ListFormat.PreserveLines || preserveSourceNewlines) { if (format & ListFormat.PreferNewLine) { return 1; } - const lastChild = lastOrUndefined(children); if (lastChild === undefined) { return !parentNode || currentSourceFile && rangeIsOnSingleLine(parentNode, currentSourceFile) ? 0 : 1; } if (currentSourceFile && parentNode && !positionIsSynthesized(parentNode.pos) && !nodeIsSynthesized(lastChild) && (!lastChild.parent || lastChild.parent === parentNode)) { if (preserveSourceNewlines) { - const end = isNodeArray(children) && !positionIsSynthesized(children.end) ? children.end : lastChild.end; + const end = childrenTextRange && !positionIsSynthesized(childrenTextRange.end) ? childrenTextRange.end : lastChild.end; return getEffectiveLines( includeComments => getLinesBetweenPositionAndNextNonWhitespaceCharacter( end, @@ -4812,7 +4846,7 @@ namespace ts { } function writeLineSeparatorsAndIndentBefore(node: Node, parent: Node): boolean { - const leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, [node], ListFormat.None); + const leadingNewlines = preserveSourceNewlines && getLeadingLineTerminatorCount(parent, node, ListFormat.None); if (leadingNewlines) { writeLinesAndIndent(leadingNewlines, /*writeSpaceIfNotIndenting*/ false); } @@ -4820,7 +4854,7 @@ namespace ts { } function writeLineSeparatorsAfter(node: Node, parent: Node) { - const trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, [node], ListFormat.None); + const trailingNewlines = preserveSourceNewlines && getClosingLineTerminatorCount(parent, node, ListFormat.None, /*childrenTextRange*/ undefined); if (trailingNewlines) { writeLine(trailingNewlines); } diff --git a/src/compiler/factory/nodeFactory.ts b/src/compiler/factory/nodeFactory.ts index cbeb8df5e5b25..802be480af42d 100644 --- a/src/compiler/factory/nodeFactory.ts +++ b/src/compiler/factory/nodeFactory.ts @@ -1,6 +1,12 @@ namespace ts { let nextAutoGenerateId = 0; + /** + * Indicates a parameter that is reserved for future use or future removal. + */ + /* @internal */ + export const RESERVED = null; // eslint-disable-line no-null/no-null + /* @internal */ export const enum NodeFactoryFlags { None = 0, @@ -579,15 +585,8 @@ namespace ts { function createBaseDeclaration( kind: T["kind"], - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined ) { const node = createBaseNode(kind); - node.decorators = asNodeArray(decorators); - node.modifiers = asNodeArray(modifiers); - node.transformFlags |= - propagateChildrenFlags(node.decorators) | - propagateChildrenFlags(node.modifiers); // NOTE: The following properties are commonly set by the binder and are added here to // ensure declarations have a stable shape. node.symbol = undefined!; // initialized by binder @@ -599,17 +598,20 @@ namespace ts { function createBaseNamedDeclaration( kind: T["kind"], - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern | string | undefined ) { - const node = createBaseDeclaration( - kind, - decorators, - modifiers - ); + Debug.assert(decorators === RESERVED, "Decorators have been merged with modifiers. If you're seeing this message you've likely accessed the factory via a non-public API."); + + const node = createBaseDeclaration(kind); name = asName(name); node.name = name; + if (canHaveModifiers(node)) { + (node as Mutable).modifiers = asNodeArray(modifiers); + (node as Mutable).transformFlags |= propagateChildrenFlags(node.modifiers); + // node.decorators = filter(node.modifiers, isDecorator); + } // The PropertyName of a member is allowed to be `await`. // We don't need to exclude `await` for type signatures since types @@ -636,8 +638,8 @@ namespace ts { function createBaseGenericNamedDeclaration }>( kind: T["kind"], - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern | string | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined ) { @@ -655,8 +657,8 @@ namespace ts { function createBaseSignatureDeclaration( kind: T["kind"], - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern | string | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, @@ -675,19 +677,24 @@ namespace ts { propagateChildrenFlags(node.parameters) | propagateChildFlags(node.type); if (type) node.transformFlags |= TransformFlags.ContainsTypeScript; + + // The following properties are used for quick info + node.typeArguments = undefined; return node; } - function updateBaseSignatureDeclaration(updated: Mutable, original: T) { - // copy children used only for error reporting - if (original.typeArguments) updated.typeArguments = original.typeArguments; + function finishUpdateBaseSignatureDeclaration(updated: Mutable, original: T) { + if (updated !== original) { + // copy children used for quick info + updated.typeArguments = original.typeArguments; + } return update(updated, original); } function createBaseFunctionLikeDeclaration( kind: T["kind"], - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: Identifier | PrivateIdentifier | StringLiteralLike | NumericLiteral | ComputedPropertyName | BindingPattern | string | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[] | undefined, @@ -709,17 +716,10 @@ namespace ts { return node; } - function updateBaseFunctionLikeDeclaration(updated: Mutable, original: T) { - // copy children used only for error reporting - if (original.exclamationToken) updated.exclamationToken = original.exclamationToken; - if (original.typeArguments) updated.typeArguments = original.typeArguments; - return updateBaseSignatureDeclaration(updated, original); - } - function createBaseInterfaceOrClassLikeDeclaration( kind: T["kind"], - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined @@ -738,8 +738,8 @@ namespace ts { function createBaseClassLikeDeclaration( kind: T["kind"], - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, @@ -760,8 +760,8 @@ namespace ts { function createBaseBindingLikeDeclaration( kind: T["kind"], - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: string | T["name"] | undefined, initializer: Expression | undefined ) { @@ -778,8 +778,8 @@ namespace ts { function createBaseVariableLikeDeclaration( kind: T["kind"], - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: string | T["name"] | undefined, type: TypeNode | undefined, initializer: Expression | undefined @@ -1134,26 +1134,10 @@ namespace ts { // // @api - function createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; - /** @deprecated */ - function createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; - function createTypeParameterDeclaration(modifiersOrName: readonly Modifier[] | string | Identifier | undefined , nameOrConstraint?: string | Identifier | TypeNode, constraintOrDefault?: TypeNode, defaultType?: TypeNode) { - let name; - let modifiers; - let constraint; - if (modifiersOrName === undefined || isArray(modifiersOrName)) { - modifiers = modifiersOrName; - name = nameOrConstraint as string | Identifier; - constraint = constraintOrDefault; - } - else { - modifiers = undefined; - name = modifiersOrName; - constraint = nameOrConstraint as TypeNode | undefined; - } + function createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration { const node = createBaseNamedDeclaration( SyntaxKind.TypeParameter, - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, name ); @@ -1164,23 +1148,7 @@ namespace ts { } // @api - function updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - /** @deprecated */ - function updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - function updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiersOrName: readonly Modifier[] | Identifier | undefined, nameOrConstraint: Identifier | TypeNode | undefined, constraintOrDefault: TypeNode | undefined, defaultType?: TypeNode | undefined) { - let name; - let modifiers; - let constraint; - if (modifiersOrName === undefined || isArray(modifiersOrName)) { - modifiers = modifiersOrName; - name = nameOrConstraint as Identifier; - constraint = constraintOrDefault; - } - else { - modifiers = undefined; - name = modifiersOrName; - constraint = nameOrConstraint as TypeNode | undefined; - } + function updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration { return node.modifiers !== modifiers || node.name !== name || node.constraint !== constraint @@ -1191,8 +1159,8 @@ namespace ts { // @api function createParameterDeclaration( - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, @@ -1226,16 +1194,15 @@ namespace ts { // @api function updateParameterDeclaration( node: ParameterDeclaration, - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.dotDotDotToken !== dotDotDotToken || node.name !== name || node.questionToken !== questionToken @@ -1269,27 +1236,30 @@ namespace ts { // @api function createPropertySignature( - modifiers: readonly Modifier[] | undefined, + modifiers: readonly ModifierLike[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined ): PropertySignature { const node = createBaseNamedDeclaration( SyntaxKind.PropertySignature, - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, name ); node.type = type; node.questionToken = questionToken; node.transformFlags = TransformFlags.ContainsTypeScript; + + // The following properties are used only to report grammar errors + node.illegalInitializer = undefined; return node; } // @api function updatePropertySignature( node: PropertySignature, - modifiers: readonly Modifier[] | undefined, + modifiers: readonly ModifierLike[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined @@ -1298,14 +1268,22 @@ namespace ts { || node.name !== name || node.questionToken !== questionToken || node.type !== type - ? update(createPropertySignature(modifiers, name, questionToken, type), node) + ? finishUpdatePropertySignature(createPropertySignature(modifiers, name, questionToken, type), node) : node; } + function finishUpdatePropertySignature(updated: Mutable, original: PropertySignature) { + if (updated !== original) { + // copy children used only for error reporting + updated.illegalInitializer = original.illegalInitializer; + } + return update(updated, original); + } + // @api function createPropertyDeclaration( - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, @@ -1337,15 +1315,14 @@ namespace ts { // @api function updatePropertyDeclaration( node: PropertyDeclaration, - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.name !== name || node.questionToken !== (questionOrExclamationToken !== undefined && isQuestionToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined) || node.exclamationToken !== (questionOrExclamationToken !== undefined && isExclamationToken(questionOrExclamationToken) ? questionOrExclamationToken : undefined) @@ -1357,7 +1334,7 @@ namespace ts { // @api function createMethodSignature( - modifiers: readonly Modifier[] | undefined, + modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, @@ -1366,7 +1343,7 @@ namespace ts { ) { const node = createBaseSignatureDeclaration( SyntaxKind.MethodSignature, - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, name, typeParameters, @@ -1381,7 +1358,7 @@ namespace ts { // @api function updateMethodSignature( node: MethodSignature, - modifiers: readonly Modifier[] | undefined, + modifiers: readonly ModifierLike[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: NodeArray | undefined, @@ -1394,14 +1371,14 @@ namespace ts { || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateBaseSignatureDeclaration(createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type), node) + ? finishUpdateBaseSignatureDeclaration(createMethodSignature(modifiers, name, questionToken, typeParameters, parameters, type), node) : node; } // @api function createMethodDeclaration( - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, @@ -1440,14 +1417,17 @@ namespace ts { else if (asteriskToken) { node.transformFlags |= TransformFlags.ContainsGenerator; } + + // The following properties are used only to report grammar errors + node.illegalExclamationToken = undefined; return node; } // @api function updateMethodDeclaration( node: MethodDeclaration, - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, @@ -1456,8 +1436,7 @@ namespace ts { type: TypeNode | undefined, body: Block | undefined ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.asteriskToken !== asteriskToken || node.name !== name || node.questionToken !== questionToken @@ -1465,49 +1444,69 @@ namespace ts { || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateBaseFunctionLikeDeclaration(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) + ? finishUpdateMethodDeclaration(createMethodDeclaration(decorators, modifiers, asteriskToken, name, questionToken, typeParameters, parameters, type, body), node) : node; } + function finishUpdateMethodDeclaration(updated: Mutable, original: MethodDeclaration) { + if (updated !== original) { + updated.illegalExclamationToken = original.illegalExclamationToken; + } + return update(updated, original); + } + // @api function createClassStaticBlockDeclaration( - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: null, body: Block ): ClassStaticBlockDeclaration { + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); + Debug.assert(modifiers === RESERVED, "This node does not support modifiers. If you're seeing this message you've likely accessed the factory via a non-public API."); const node = createBaseGenericNamedDeclaration( SyntaxKind.ClassStaticBlockDeclaration, decorators, - modifiers, + /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined ); node.body = body; node.transformFlags = propagateChildFlags(body) | TransformFlags.ContainsClassFields; + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; + node.illegalModifiers = undefined; return node; } // @api function updateClassStaticBlockDeclaration( node: ClassStaticBlockDeclaration, - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: null, body: Block ): ClassStaticBlockDeclaration { - return node.decorators !== decorators - || node.modifier !== modifiers - || node.body !== body - ? update(createClassStaticBlockDeclaration(decorators, modifiers, body), node) + return node.body !== body + ? finishUpdateClassStaticBlockDeclaration(createClassStaticBlockDeclaration(decorators, modifiers, body), node) : node; } + function finishUpdateClassStaticBlockDeclaration(updated: Mutable, original: ClassStaticBlockDeclaration) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + updated.illegalModifiers = original.illegalModifiers; + } + return update(updated, original); + } + // @api function createConstructorDeclaration( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined ) { + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); const node = createBaseFunctionLikeDeclaration( SyntaxKind.Constructor, decorators, @@ -1519,35 +1518,48 @@ namespace ts { body ); node.transformFlags |= TransformFlags.ContainsES2015; + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; + node.illegalTypeParameters = undefined; + node.illegalType = undefined; return node; } // @api function updateConstructorDeclaration( node: ConstructorDeclaration, - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.parameters !== parameters || node.body !== body - ? updateBaseFunctionLikeDeclaration(createConstructorDeclaration(decorators, modifiers, parameters, body), node) + ? finishUpdateConstructorDeclaration(createConstructorDeclaration(decorators, modifiers, parameters, body), node) : node; } + function finishUpdateConstructorDeclaration(updated: Mutable, original: ConstructorDeclaration) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + updated.illegalTypeParameters = original.illegalTypeParameters; + updated.illegalType = original.illegalType; + } + return finishUpdateBaseSignatureDeclaration(updated, original); + } + // @api function createGetAccessorDeclaration( - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined ) { - return createBaseFunctionLikeDeclaration( + const node = createBaseFunctionLikeDeclaration( SyntaxKind.GetAccessor, decorators, modifiers, @@ -1557,37 +1569,47 @@ namespace ts { type, body ); + + // The following properties are used only to report grammar errors + node.illegalTypeParameters = undefined; + return node; } // @api function updateGetAccessorDeclaration( node: GetAccessorDeclaration, - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateBaseFunctionLikeDeclaration(createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body), node) + ? finishUpdateGetAccessorDeclaration(createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body), node) : node; } + function finishUpdateGetAccessorDeclaration(updated: Mutable, original: GetAccessorDeclaration) { + if (updated !== original) { + updated.illegalTypeParameters = original.illegalTypeParameters; + } + return finishUpdateBaseSignatureDeclaration(updated, original); + } + // @api function createSetAccessorDeclaration( - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined ) { - return createBaseFunctionLikeDeclaration( + const node = createBaseFunctionLikeDeclaration( SyntaxKind.SetAccessor, decorators, modifiers, @@ -1597,26 +1619,38 @@ namespace ts { /*type*/ undefined, body ); + + // The following properties are used only to report grammar errors + node.illegalTypeParameters = undefined; + node.illegalType = undefined; + return node; } // @api function updateSetAccessorDeclaration( node: SetAccessorDeclaration, - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.name !== name || node.parameters !== parameters || node.body !== body - ? updateBaseFunctionLikeDeclaration(createSetAccessorDeclaration(decorators, modifiers, name, parameters, body), node) + ? finishUpdateSetAccessorDeclaration(createSetAccessorDeclaration(decorators, modifiers, name, parameters, body), node) : node; } + function finishUpdateSetAccessorDeclaration(updated: Mutable, original: SetAccessorDeclaration) { + if (updated !== original) { + updated.illegalTypeParameters = original.illegalTypeParameters; + updated.illegalType = original.illegalType; + } + return finishUpdateBaseSignatureDeclaration(updated, original); + } + // @api function createCallSignature( typeParameters: readonly TypeParameterDeclaration[] | undefined, @@ -1625,7 +1659,7 @@ namespace ts { ): CallSignatureDeclaration { const node = createBaseSignatureDeclaration( SyntaxKind.CallSignature, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, @@ -1646,7 +1680,7 @@ namespace ts { return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateBaseSignatureDeclaration(createCallSignature(typeParameters, parameters, type), node) + ? finishUpdateBaseSignatureDeclaration(createCallSignature(typeParameters, parameters, type), node) : node; } @@ -1658,7 +1692,7 @@ namespace ts { ): ConstructSignatureDeclaration { const node = createBaseSignatureDeclaration( SyntaxKind.ConstructSignature, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, @@ -1679,17 +1713,18 @@ namespace ts { return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateBaseSignatureDeclaration(createConstructSignature(typeParameters, parameters, type), node) + ? finishUpdateBaseSignatureDeclaration(createConstructSignature(typeParameters, parameters, type), node) : node; } // @api function createIndexSignature( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined ): IndexSignatureDeclaration { + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); const node = createBaseSignatureDeclaration( SyntaxKind.IndexSignature, decorators, @@ -1706,16 +1741,15 @@ namespace ts { // @api function updateIndexSignature( node: IndexSignatureDeclaration, - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode ) { return node.parameters !== parameters || node.type !== type - || node.decorators !== decorators || node.modifiers !== modifiers - ? updateBaseSignatureDeclaration(createIndexSignature(decorators, modifiers, parameters, type), node) + ? finishUpdateBaseSignatureDeclaration(createIndexSignature(decorators, modifiers, parameters, type), node) : node; } @@ -1789,7 +1823,7 @@ namespace ts { ): FunctionTypeNode { const node = createBaseSignatureDeclaration( SyntaxKind.FunctionType, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*name*/ undefined, typeParameters, @@ -1797,6 +1831,9 @@ namespace ts { type ); node.transformFlags = TransformFlags.ContainsTypeScript; + + // The following properties are used only to report grammar errors + node.illegalModifiers = undefined; return node; } @@ -1810,10 +1847,17 @@ namespace ts { return node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateBaseSignatureDeclaration(createFunctionTypeNode(typeParameters, parameters, type), node) + ? finishUpdateFunctionTypeNode(createFunctionTypeNode(typeParameters, parameters, type), node) : node; } + function finishUpdateFunctionTypeNode(updated: Mutable, original: FunctionTypeNode) { + if (updated !== original) { + updated.illegalModifiers = original.illegalModifiers; + } + return finishUpdateBaseSignatureDeclaration(updated, original); + } + // @api function createConstructorTypeNode(...args: Parameters) { return args.length === 4 ? createConstructorTypeNode1(...args) : @@ -1829,7 +1873,7 @@ namespace ts { ): ConstructorTypeNode { const node = createBaseSignatureDeclaration( SyntaxKind.ConstructorType, - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, /*name*/ undefined, typeParameters, @@ -1867,7 +1911,7 @@ namespace ts { || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type - ? updateBaseSignatureDeclaration(createConstructorTypeNode(modifiers, typeParameters, parameters, type), node) + ? finishUpdateBaseSignatureDeclaration(createConstructorTypeNode(modifiers, typeParameters, parameters, type), node) : node; } @@ -2081,24 +2125,16 @@ namespace ts { } // @api - function createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; - function createImportTypeNode(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; function createImportTypeNode( argument: TypeNode, - qualifierOrAssertions?: EntityName | ImportTypeAssertionContainer, - typeArgumentsOrQualifier?: readonly TypeNode[] | EntityName, - isTypeOfOrTypeArguments?: boolean | readonly TypeNode[], - isTypeOf?: boolean - ) { - const assertion = qualifierOrAssertions && qualifierOrAssertions.kind === SyntaxKind.ImportTypeAssertionContainer ? qualifierOrAssertions : undefined; - const qualifier = qualifierOrAssertions && isEntityName(qualifierOrAssertions) ? qualifierOrAssertions - : typeArgumentsOrQualifier && !isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; - const typeArguments = isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; - isTypeOf = typeof isTypeOfOrTypeArguments === "boolean" ? isTypeOfOrTypeArguments : typeof isTypeOf === "boolean" ? isTypeOf : false; - + assertions?: ImportTypeAssertionContainer, + qualifier?: EntityName, + typeArguments?: readonly TypeNode[], + isTypeOf = false + ): ImportTypeNode { const node = createBaseNode(SyntaxKind.ImportType); node.argument = argument; - node.assertions = assertion; + node.assertions = assertions; node.qualifier = qualifier; node.typeArguments = typeArguments && parenthesizerRules().parenthesizeTypeArguments(typeArguments); node.isTypeOf = isTypeOf; @@ -2107,28 +2143,20 @@ namespace ts { } // @api - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; - function updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, assertions: ImportTypeAssertionContainer | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; function updateImportTypeNode( node: ImportTypeNode, argument: TypeNode, - qualifierOrAssertions: EntityName | ImportTypeAssertionContainer | undefined, - typeArgumentsOrQualifier: readonly TypeNode[] | EntityName | undefined, - isTypeOfOrTypeArguments: boolean | readonly TypeNode[] | undefined, - isTypeOf?: boolean | undefined - ) { - const assertion = qualifierOrAssertions && qualifierOrAssertions.kind === SyntaxKind.ImportTypeAssertionContainer ? qualifierOrAssertions : undefined; - const qualifier = qualifierOrAssertions && isEntityName(qualifierOrAssertions) ? qualifierOrAssertions - : typeArgumentsOrQualifier && !isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : undefined; - const typeArguments = isArray(typeArgumentsOrQualifier) ? typeArgumentsOrQualifier : isArray(isTypeOfOrTypeArguments) ? isTypeOfOrTypeArguments : undefined; - isTypeOf = typeof isTypeOfOrTypeArguments === "boolean" ? isTypeOfOrTypeArguments : typeof isTypeOf === "boolean" ? isTypeOf : node.isTypeOf; - + assertions: ImportTypeAssertionContainer | undefined, + qualifier: EntityName | undefined, + typeArguments: readonly TypeNode[] | undefined, + isTypeOf: boolean = node.isTypeOf + ): ImportTypeNode { return node.argument !== argument - || node.assertions !== assertion + || node.assertions !== assertions || node.qualifier !== qualifier || node.typeArguments !== typeArguments || node.isTypeOf !== isTypeOf - ? update(createImportTypeNode(argument, assertion, qualifier, typeArguments, isTypeOf), node) + ? update(createImportTypeNode(argument, assertions, qualifier, typeArguments, isTypeOf), node) : node; } @@ -2278,7 +2306,7 @@ namespace ts { function createBindingElement(dotDotDotToken: DotDotDotToken | undefined, propertyName: string | PropertyName | undefined, name: string | BindingName, initializer?: Expression) { const node = createBaseBindingLikeDeclaration( SyntaxKind.BindingElement, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, name, initializer && parenthesizerRules().parenthesizeExpressionForDisallowedComma(initializer) @@ -2630,7 +2658,7 @@ namespace ts { // @api function createFunctionExpression( - modifiers: readonly Modifier[] | undefined, + modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, @@ -2640,7 +2668,7 @@ namespace ts { ) { const node = createBaseFunctionLikeDeclaration( SyntaxKind.FunctionExpression, - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, name, typeParameters, @@ -2670,7 +2698,7 @@ namespace ts { // @api function updateFunctionExpression( node: FunctionExpression, - modifiers: readonly Modifier[] | undefined, + modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, @@ -2685,13 +2713,13 @@ namespace ts { || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateBaseFunctionLikeDeclaration(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) + ? finishUpdateBaseSignatureDeclaration(createFunctionExpression(modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } // @api function createArrowFunction( - modifiers: readonly Modifier[] | undefined, + modifiers: readonly ModifierLike[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, @@ -2700,7 +2728,7 @@ namespace ts { ) { const node = createBaseFunctionLikeDeclaration( SyntaxKind.ArrowFunction, - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, /*name*/ undefined, typeParameters, @@ -2721,7 +2749,7 @@ namespace ts { // @api function updateArrowFunction( node: ArrowFunction, - modifiers: readonly Modifier[] | undefined, + modifiers: readonly ModifierLike[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, @@ -2734,7 +2762,7 @@ namespace ts { || node.type !== type || node.equalsGreaterThanToken !== equalsGreaterThanToken || node.body !== body - ? updateBaseFunctionLikeDeclaration(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) + ? finishUpdateBaseSignatureDeclaration(createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanToken, body), node) : node; } @@ -3072,8 +3100,8 @@ namespace ts { // @api function createClassExpression( - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, @@ -3095,15 +3123,14 @@ namespace ts { // @api function updateClassExpression( node: ClassExpression, - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[] ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses @@ -3275,9 +3302,11 @@ namespace ts { // @api function createVariableStatement(modifiers: readonly Modifier[] | undefined, declarationList: VariableDeclarationList | readonly VariableDeclaration[]) { - const node = createBaseDeclaration(SyntaxKind.VariableStatement, /*decorators*/ undefined, modifiers); + const node = createBaseDeclaration(SyntaxKind.VariableStatement); + node.modifiers = asNodeArray(modifiers); node.declarationList = isArray(declarationList) ? createVariableDeclarationList(declarationList) : declarationList; node.transformFlags |= + propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.declarationList); if (modifiersToFlags(node.modifiers) & ModifierFlags.Ambient) { node.transformFlags = TransformFlags.ContainsTypeScript; @@ -3603,7 +3632,7 @@ namespace ts { function createVariableDeclaration(name: string | BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) { const node = createBaseVariableLikeDeclaration( SyntaxKind.VariableDeclaration, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, name, type, @@ -3652,8 +3681,8 @@ namespace ts { // @api function createFunctionDeclaration( - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, @@ -3691,14 +3720,17 @@ namespace ts { node.transformFlags |= TransformFlags.ContainsGenerator; } } + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; return node; } // @api function updateFunctionDeclaration( node: FunctionDeclaration, - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, @@ -3706,22 +3738,29 @@ namespace ts { type: TypeNode | undefined, body: Block | undefined ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.asteriskToken !== asteriskToken || node.name !== name || node.typeParameters !== typeParameters || node.parameters !== parameters || node.type !== type || node.body !== body - ? updateBaseFunctionLikeDeclaration(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) + ? finishUpdateFunctionDeclaration(createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body), node) : node; } + function finishUpdateFunctionDeclaration(updated: Mutable, original: FunctionDeclaration) { + if (updated !== original) { + // copy children used only for error reporting + updated.illegalDecorators = original.illegalDecorators; + } + return finishUpdateBaseSignatureDeclaration(updated, original); + } + // @api function createClassDeclaration( - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, @@ -3751,15 +3790,14 @@ namespace ts { // @api function updateClassDeclaration( node: ClassDeclaration, - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, + decorators: null, + modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[] ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses @@ -3770,13 +3808,14 @@ namespace ts { // @api function createInterfaceDeclaration( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[] ) { + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); const node = createBaseInterfaceOrClassLikeDeclaration( SyntaxKind.InterfaceDeclaration, decorators, @@ -3787,37 +3826,47 @@ namespace ts { ); node.members = createNodeArray(members); node.transformFlags = TransformFlags.ContainsTypeScript; + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; return node; } // @api function updateInterfaceDeclaration( node: InterfaceDeclaration, - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[] ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.heritageClauses !== heritageClauses || node.members !== members - ? update(createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) + ? finishUpdateInterfaceDeclaration(createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members), node) : node; } + function finishUpdateInterfaceDeclaration(updated: Mutable, original: InterfaceDeclaration) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + // @api function createTypeAliasDeclaration( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode ) { + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); const node = createBaseGenericNamedDeclaration( SyntaxKind.TypeAliasDeclaration, decorators, @@ -3827,34 +3876,44 @@ namespace ts { ); node.type = type; node.transformFlags = TransformFlags.ContainsTypeScript; + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; return node; } // @api function updateTypeAliasDeclaration( node: TypeAliasDeclaration, - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.name !== name || node.typeParameters !== typeParameters || node.type !== type - ? update(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node) + ? finishUpdateTypeAliasDeclaration(createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type), node) : node; } + function finishUpdateTypeAliasDeclaration(updated: Mutable, original: TypeAliasDeclaration) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + // @api function createEnumDeclaration( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[] ) { + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); const node = createBaseNamedDeclaration( SyntaxKind.EnumDeclaration, decorators, @@ -3866,37 +3925,45 @@ namespace ts { propagateChildrenFlags(node.members) | TransformFlags.ContainsTypeScript; node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // Enum declarations cannot contain `await` + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; return node; } // @api function updateEnumDeclaration( node: EnumDeclaration, - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.name !== name || node.members !== members - ? update(createEnumDeclaration(decorators, modifiers, name, members), node) + ? finishUpdateEnumDeclaration(createEnumDeclaration(decorators, modifiers, name, members), node) : node; } + function finishUpdateEnumDeclaration(updated: Mutable, original: EnumDeclaration) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + // @api function createModuleDeclaration( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags = NodeFlags.None ) { - const node = createBaseDeclaration( - SyntaxKind.ModuleDeclaration, - decorators, - modifiers - ); + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); + + const node = createBaseDeclaration(SyntaxKind.ModuleDeclaration); + node.modifiers = asNodeArray(modifiers); node.flags |= flags & (NodeFlags.Namespace | NodeFlags.NestedNamespace | NodeFlags.GlobalAugmentation); node.name = name; node.body = body; @@ -3905,30 +3972,40 @@ namespace ts { } else { node.transformFlags |= + propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.name) | propagateChildFlags(node.body) | TransformFlags.ContainsTypeScript; } node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // Module declarations cannot contain `await`. + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; return node; } // @api function updateModuleDeclaration( node: ModuleDeclaration, - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.name !== name || node.body !== body - ? update(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) + ? finishUpdateModuleDeclaration(createModuleDeclaration(decorators, modifiers, name, body, node.flags), node) : node; } + function finishUpdateModuleDeclaration(updated: Mutable, original: ModuleDeclaration) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + // @api function createModuleBlock(statements: readonly Statement[]) { const node = createBaseNode(SyntaxKind.ModuleBlock); @@ -3963,29 +4040,42 @@ namespace ts { function createNamespaceExportDeclaration(name: string | Identifier) { const node = createBaseNamedDeclaration( SyntaxKind.NamespaceExportDeclaration, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, name ); node.transformFlags = TransformFlags.ContainsTypeScript; + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; + node.illegalModifiers = undefined; return node; } // @api function updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier) { return node.name !== name - ? update(createNamespaceExportDeclaration(name), node) + ? finishUpdateNamespaceExportDeclaration(createNamespaceExportDeclaration(name), node) : node; } + function finishUpdateNamespaceExportDeclaration(updated: Mutable, original: NamespaceExportDeclaration) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + updated.illegalModifiers = original.illegalModifiers; + } + return update(updated, original); + } + // @api function createImportEqualsDeclaration( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference ) { + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); const node = createBaseNamedDeclaration( SyntaxKind.ImportEqualsDeclaration, decorators, @@ -3997,40 +4087,48 @@ namespace ts { node.transformFlags |= propagateChildFlags(node.moduleReference); if (!isExternalModuleReference(node.moduleReference)) node.transformFlags |= TransformFlags.ContainsTypeScript; node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // Import= declaration is always parsed in an Await context + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; return node; } // @api function updateImportEqualsDeclaration( node: ImportEqualsDeclaration, - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.isTypeOnly !== isTypeOnly || node.name !== name || node.moduleReference !== moduleReference - ? update(createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference), node) + ? finishUpdateImportEqualsDeclaration(createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, name, moduleReference), node) : node; } + function finishUpdateImportEqualsDeclaration(updated: Mutable, original: ImportEqualsDeclaration) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + // @api function createImportDeclaration( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined ): ImportDeclaration { - const node = createBaseDeclaration( - SyntaxKind.ImportDeclaration, - decorators, - modifiers - ); + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); + + const node = createBaseDeclaration(SyntaxKind.ImportDeclaration); + node.modifiers = asNodeArray(modifiers); node.importClause = importClause; node.moduleSpecifier = moduleSpecifier; node.assertClause = assertClause; @@ -4038,27 +4136,36 @@ namespace ts { propagateChildFlags(node.importClause) | propagateChildFlags(node.moduleSpecifier); node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; return node; } // @api function updateImportDeclaration( node: ImportDeclaration, - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.importClause !== importClause || node.moduleSpecifier !== moduleSpecifier || node.assertClause !== assertClause - ? update(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause), node) + ? finishUpdateImportDeclaration(createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause), node) : node; } + function finishUpdateImportDeclaration(updated: Mutable, original: ImportDeclaration) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + // @api function createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause { const node = createBaseNode(SyntaxKind.ImportClause); @@ -4208,84 +4315,101 @@ namespace ts { // @api function createExportAssignment( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression ) { - const node = createBaseDeclaration( - SyntaxKind.ExportAssignment, - decorators, - modifiers - ); + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); + + const node = createBaseDeclaration(SyntaxKind.ExportAssignment); + node.modifiers = asNodeArray(modifiers); node.isExportEquals = isExportEquals; node.expression = isExportEquals ? parenthesizerRules().parenthesizeRightSideOfBinary(SyntaxKind.EqualsToken, /*leftSide*/ undefined, expression) : parenthesizerRules().parenthesizeExpressionOfExportDefault(expression); - node.transformFlags |= propagateChildFlags(node.expression); + node.transformFlags |= propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.expression); node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; return node; } // @api function updateExportAssignment( node: ExportAssignment, - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, expression: Expression ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.expression !== expression - ? update(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) + ? finishUpdateExportAssignment(createExportAssignment(decorators, modifiers, node.isExportEquals, expression), node) : node; } + function finishUpdateExportAssignment(updated: Mutable, original: ExportAssignment) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + // @api function createExportDeclaration( - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause ) { - const node = createBaseDeclaration( - SyntaxKind.ExportDeclaration, - decorators, - modifiers - ); + Debug.assert(decorators === RESERVED, "This node does not support decorators. If you're seeing this message you've likely accessed the factory via a non-public API."); + + const node = createBaseDeclaration(SyntaxKind.ExportDeclaration); + node.modifiers = asNodeArray(modifiers); node.isTypeOnly = isTypeOnly; node.exportClause = exportClause; node.moduleSpecifier = moduleSpecifier; node.assertClause = assertClause; node.transformFlags |= + propagateChildrenFlags(node.modifiers) | propagateChildFlags(node.exportClause) | propagateChildFlags(node.moduleSpecifier); node.transformFlags &= ~TransformFlags.ContainsPossibleTopLevelAwait; // always parsed in an Await context + + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; return node; } // @api function updateExportDeclaration( node: ExportDeclaration, - decorators: readonly Decorator[] | undefined, + decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined ) { - return node.decorators !== decorators - || node.modifiers !== modifiers + return node.modifiers !== modifiers || node.isTypeOnly !== isTypeOnly || node.exportClause !== exportClause || node.moduleSpecifier !== moduleSpecifier || node.assertClause !== assertClause - ? update(createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause), node) + ? finishUpdateExportDeclaration(createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause), node) : node; } + function finishUpdateExportDeclaration(updated: Mutable, original: ExportDeclaration) { + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + } + return update(updated, original); + } + // @api function createNamedExports(elements: readonly ExportSpecifier[]) { const node = createBaseNode(SyntaxKind.NamedExports); @@ -4325,12 +4449,8 @@ namespace ts { } // @api - function createMissingDeclaration() { - const node = createBaseDeclaration( - SyntaxKind.MissingDeclaration, - /*decorators*/ undefined, - /*modifiers*/ undefined - ); + function createMissingDeclaration(): MissingDeclaration { + const node = createBaseDeclaration(SyntaxKind.MissingDeclaration); return node; } @@ -4410,7 +4530,7 @@ namespace ts { function createJSDocFunctionType(parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): JSDocFunctionType { const node = createBaseSignatureDeclaration( SyntaxKind.JSDocFunctionType, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -5136,7 +5256,7 @@ namespace ts { function createPropertyAssignment(name: string | PropertyName, initializer: Expression) { const node = createBaseNamedDeclaration( SyntaxKind.PropertyAssignment, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, name ); @@ -5144,16 +5264,13 @@ namespace ts { node.transformFlags |= propagateChildFlags(node.name) | propagateChildFlags(node.initializer); - return node; - } - function finishUpdatePropertyAssignment(updated: Mutable, original: PropertyAssignment) { - // copy children used only for error reporting - if (original.decorators) updated.decorators = original.decorators; - if (original.modifiers) updated.modifiers = original.modifiers; - if (original.questionToken) updated.questionToken = original.questionToken; - if (original.exclamationToken) updated.exclamationToken = original.exclamationToken; - return update(updated, original); + // The following properties are used only to report grammar errors + node.illegalDecorators = undefined; + node.illegalModifiers = undefined; + node.illegalQuestionToken = undefined; + node.illegalExclamationToken = undefined; + return node; } // @api @@ -5164,11 +5281,22 @@ namespace ts { : node; } + function finishUpdatePropertyAssignment(updated: Mutable, original: PropertyAssignment) { + // copy children used only for error reporting + if (updated !== original) { + updated.illegalDecorators = original.illegalDecorators; + updated.illegalModifiers = original.illegalModifiers; + updated.illegalQuestionToken = original.illegalQuestionToken; + updated.illegalExclamationToken = original.illegalExclamationToken; + } + return update(updated, original); + } + // @api function createShorthandPropertyAssignment(name: string | Identifier, objectAssignmentInitializer?: Expression) { const node = createBaseNamedDeclaration( SyntaxKind.ShorthandPropertyAssignment, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, name ); @@ -5176,17 +5304,14 @@ namespace ts { node.transformFlags |= propagateChildFlags(node.objectAssignmentInitializer) | TransformFlags.ContainsES2015; - return node; - } - function finishUpdateShorthandPropertyAssignment(updated: Mutable, original: ShorthandPropertyAssignment) { - // copy children used only for error reporting - if (original.decorators) updated.decorators = original.decorators; - if (original.modifiers) updated.modifiers = original.modifiers; - if (original.equalsToken) updated.equalsToken = original.equalsToken; - if (original.questionToken) updated.questionToken = original.questionToken; - if (original.exclamationToken) updated.exclamationToken = original.exclamationToken; - return update(updated, original); + // The following properties are used only to report grammar errors + node.equalsToken = undefined; + node.illegalDecorators = undefined; + node.illegalModifiers = undefined; + node.illegalQuestionToken = undefined; + node.illegalExclamationToken = undefined; + return node; } // @api @@ -5197,6 +5322,18 @@ namespace ts { : node; } + function finishUpdateShorthandPropertyAssignment(updated: Mutable, original: ShorthandPropertyAssignment) { + if (updated !== original) { + // copy children used only for error reporting + updated.equalsToken = original.equalsToken; + updated.illegalDecorators = original.illegalDecorators; + updated.illegalModifiers = original.illegalModifiers; + updated.illegalQuestionToken = original.illegalQuestionToken; + updated.illegalExclamationToken = original.illegalExclamationToken; + } + return update(updated, original); + } + // @api function createSpreadAssignment(expression: Expression) { const node = createBaseNode(SyntaxKind.SpreadAssignment); @@ -5592,7 +5729,7 @@ namespace ts { function createExportDefault(expression: Expression) { return createExportAssignment( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*isExportEquals*/ false, expression); @@ -5600,7 +5737,7 @@ namespace ts { function createExternalModuleExport(exportName: Identifier) { return createExportDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, createNamedExports([ @@ -5853,11 +5990,11 @@ namespace ts { createParenthesizedExpression( createObjectLiteralExpression([ createSetAccessorDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, "value", [createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, paramName, @@ -6198,29 +6335,31 @@ namespace ts { else { modifierArray = modifiers; } - return isParameter(node) ? updateParameterDeclaration(node, node.decorators, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : + return isTypeParameterDeclaration(node) ? updateTypeParameterDeclaration(node, modifierArray, node.name, node.constraint, node.default) : + isParameter(node) ? updateParameterDeclaration(node, RESERVED, modifierArray, node.dotDotDotToken, node.name, node.questionToken, node.type, node.initializer) : + isConstructorTypeNode(node) ? updateConstructorTypeNode1(node, modifierArray, node.typeParameters, node.parameters, node.type) : isPropertySignature(node) ? updatePropertySignature(node, modifierArray, node.name, node.questionToken, node.type) : - isPropertyDeclaration(node) ? updatePropertyDeclaration(node, node.decorators, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : + isPropertyDeclaration(node) ? updatePropertyDeclaration(node, RESERVED, modifierArray, node.name, node.questionToken ?? node.exclamationToken, node.type, node.initializer) : isMethodSignature(node) ? updateMethodSignature(node, modifierArray, node.name, node.questionToken, node.typeParameters, node.parameters, node.type) : - isMethodDeclaration(node) ? updateMethodDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : - isConstructorDeclaration(node) ? updateConstructorDeclaration(node, node.decorators, modifierArray, node.parameters, node.body) : - isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.type, node.body) : - isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, node.decorators, modifierArray, node.name, node.parameters, node.body) : - isIndexSignatureDeclaration(node) ? updateIndexSignature(node, node.decorators, modifierArray, node.parameters, node.type) : + isMethodDeclaration(node) ? updateMethodDeclaration(node, RESERVED, modifierArray, node.asteriskToken, node.name, node.questionToken, node.typeParameters, node.parameters, node.type, node.body) : + isConstructorDeclaration(node) ? updateConstructorDeclaration(node, RESERVED, modifierArray, node.parameters, node.body) : + isGetAccessorDeclaration(node) ? updateGetAccessorDeclaration(node, RESERVED, modifierArray, node.name, node.parameters, node.type, node.body) : + isSetAccessorDeclaration(node) ? updateSetAccessorDeclaration(node, RESERVED, modifierArray, node.name, node.parameters, node.body) : + isIndexSignatureDeclaration(node) ? updateIndexSignature(node, RESERVED, modifierArray, node.parameters, node.type) : isFunctionExpression(node) ? updateFunctionExpression(node, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : isArrowFunction(node) ? updateArrowFunction(node, modifierArray, node.typeParameters, node.parameters, node.type, node.equalsGreaterThanToken, node.body) : - isClassExpression(node) ? updateClassExpression(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : + isClassExpression(node) ? updateClassExpression(node, RESERVED, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : isVariableStatement(node) ? updateVariableStatement(node, modifierArray, node.declarationList) : - isFunctionDeclaration(node) ? updateFunctionDeclaration(node, node.decorators, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : - isClassDeclaration(node) ? updateClassDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : - isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : - isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, node.decorators, modifierArray, node.name, node.typeParameters, node.type) : - isEnumDeclaration(node) ? updateEnumDeclaration(node, node.decorators, modifierArray, node.name, node.members) : - isModuleDeclaration(node) ? updateModuleDeclaration(node, node.decorators, modifierArray, node.name, node.body) : - isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : - isImportDeclaration(node) ? updateImportDeclaration(node, node.decorators, modifierArray, node.importClause, node.moduleSpecifier, node.assertClause) : - isExportAssignment(node) ? updateExportAssignment(node, node.decorators, modifierArray, node.expression) : - isExportDeclaration(node) ? updateExportDeclaration(node, node.decorators, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) : + isFunctionDeclaration(node) ? updateFunctionDeclaration(node, RESERVED, modifierArray, node.asteriskToken, node.name, node.typeParameters, node.parameters, node.type, node.body) : + isClassDeclaration(node) ? updateClassDeclaration(node, RESERVED, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : + isInterfaceDeclaration(node) ? updateInterfaceDeclaration(node, RESERVED, modifierArray, node.name, node.typeParameters, node.heritageClauses, node.members) : + isTypeAliasDeclaration(node) ? updateTypeAliasDeclaration(node, RESERVED, modifierArray, node.name, node.typeParameters, node.type) : + isEnumDeclaration(node) ? updateEnumDeclaration(node, RESERVED, modifierArray, node.name, node.members) : + isModuleDeclaration(node) ? updateModuleDeclaration(node, RESERVED, modifierArray, node.name, node.body) : + isImportEqualsDeclaration(node) ? updateImportEqualsDeclaration(node, RESERVED, modifierArray, node.isTypeOnly, node.name, node.moduleReference) : + isImportDeclaration(node) ? updateImportDeclaration(node, RESERVED, modifierArray, node.importClause, node.moduleSpecifier, node.assertClause) : + isExportAssignment(node) ? updateExportAssignment(node, RESERVED, modifierArray, node.expression) : + isExportDeclaration(node) ? updateExportDeclaration(node, RESERVED, modifierArray, node.isTypeOnly, node.exportClause, node.moduleSpecifier, node.assertClause) : Debug.assertNever(node); } @@ -6253,14 +6392,14 @@ namespace ts { } } - function updateWithoutOriginal(updated: T, original: T): T { + function updateWithoutOriginal(updated: Mutable, original: T): T { if (updated !== original) { setTextRange(updated, original); } return updated; } - function updateWithOriginal(updated: T, original: T): T { + function updateWithOriginal(updated: Mutable, original: T): T { if (updated !== original) { setOriginalNode(updated, original); setTextRange(updated, original); diff --git a/src/compiler/factory/nodeTests.ts b/src/compiler/factory/nodeTests.ts index cf473caf65bf7..3d93873c0e18e 100644 --- a/src/compiler/factory/nodeTests.ts +++ b/src/compiler/factory/nodeTests.ts @@ -134,6 +134,11 @@ namespace ts { return node.kind === SyntaxKind.AbstractKeyword; } + /* @internal */ + export function isOverrideModifier(node: Node): node is OverrideKeyword { + return node.kind === SyntaxKind.OverrideKeyword; + } + /*@internal*/ export function isSuperKeyword(node: Node): node is SuperExpression { return node.kind === SyntaxKind.SuperKeyword; @@ -605,6 +610,10 @@ namespace ts { return node.kind === SyntaxKind.AssertEntry; } + export function isImportTypeAssertionContainer(node: Node): node is ImportTypeAssertionContainer { + return node.kind === SyntaxKind.ImportTypeAssertionContainer; + } + export function isNamespaceImport(node: Node): node is NamespaceImport { return node.kind === SyntaxKind.NamespaceImport; } diff --git a/src/compiler/factory/utilities.ts b/src/compiler/factory/utilities.ts index 7daa31c522732..322b9df127836 100644 --- a/src/compiler/factory/utilities.ts +++ b/src/compiler/factory/utilities.ts @@ -4,7 +4,7 @@ namespace ts { // Compound nodes export function createEmptyExports(factory: NodeFactory) { - return factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([]), /*moduleSpecifier*/ undefined); + return factory.createExportDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([]), /*moduleSpecifier*/ undefined); } export function createMemberAccessForPropertyName(factory: NodeFactory, target: Expression, memberName: PropertyName, location?: TextRange): MemberExpression { @@ -197,7 +197,7 @@ namespace ts { get: getAccessor && setTextRange( setOriginalNode( factory.createFunctionExpression( - getAccessor.modifiers, + getModifiers(getAccessor), /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -212,7 +212,7 @@ namespace ts { set: setAccessor && setTextRange( setOriginalNode( factory.createFunctionExpression( - setAccessor.modifiers, + getModifiers(setAccessor), /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, @@ -267,7 +267,7 @@ namespace ts { setOriginalNode( setTextRange( factory.createFunctionExpression( - method.modifiers, + getModifiers(method), method.asteriskToken, /*name*/ undefined, /*typeParameters*/ undefined, @@ -519,7 +519,7 @@ namespace ts { } if (namedBindings) { const externalHelpersImportDeclaration = nodeFactory.createImportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, nodeFactory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, namedBindings), nodeFactory.createStringLiteral(externalHelpersModuleNameText), @@ -865,9 +865,55 @@ namespace ts { } } - export function canHaveModifiers(node: Node): node is HasModifiers { + export function canHaveIllegalType(node: Node): node is HasIllegalType { + const kind = node.kind; + return kind === SyntaxKind.Constructor + || kind === SyntaxKind.SetAccessor; + } + + export function canHaveIllegalTypeParameters(node: Node): node is HasIllegalTypeParameters { + const kind = node.kind; + return kind === SyntaxKind.Constructor + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.SetAccessor; + } + + export function canHaveDecorators(node: Node): node is HasDecorators { const kind = node.kind; return kind === SyntaxKind.Parameter + || kind === SyntaxKind.PropertyDeclaration + || kind === SyntaxKind.MethodDeclaration + || kind === SyntaxKind.GetAccessor + || kind === SyntaxKind.SetAccessor + || kind === SyntaxKind.ClassExpression + || kind === SyntaxKind.ClassDeclaration; + } + + export function canHaveIllegalDecorators(node: Node): node is HasIllegalDecorators { + const kind = node.kind; + return kind === SyntaxKind.PropertyAssignment + || kind === SyntaxKind.ShorthandPropertyAssignment + || kind === SyntaxKind.FunctionDeclaration + || kind === SyntaxKind.Constructor + || kind === SyntaxKind.IndexSignature + || kind === SyntaxKind.ClassStaticBlockDeclaration + || kind === SyntaxKind.MissingDeclaration + || kind === SyntaxKind.VariableStatement + || kind === SyntaxKind.InterfaceDeclaration + || kind === SyntaxKind.TypeAliasDeclaration + || kind === SyntaxKind.EnumDeclaration + || kind === SyntaxKind.ModuleDeclaration + || kind === SyntaxKind.ImportEqualsDeclaration + || kind === SyntaxKind.ImportDeclaration + || kind === SyntaxKind.NamespaceExportDeclaration + || kind === SyntaxKind.ExportDeclaration + || kind === SyntaxKind.ExportAssignment; + } + + export function canHaveModifiers(node: Node): node is HasModifiers { + const kind = node.kind; + return kind === SyntaxKind.TypeParameter + || kind === SyntaxKind.Parameter || kind === SyntaxKind.PropertySignature || kind === SyntaxKind.PropertyDeclaration || kind === SyntaxKind.MethodSignature @@ -876,6 +922,7 @@ namespace ts { || kind === SyntaxKind.GetAccessor || kind === SyntaxKind.SetAccessor || kind === SyntaxKind.IndexSignature + || kind === SyntaxKind.ConstructorType || kind === SyntaxKind.FunctionExpression || kind === SyntaxKind.ArrowFunction || kind === SyntaxKind.ClassExpression @@ -892,6 +939,16 @@ namespace ts { || kind === SyntaxKind.ExportDeclaration; } + export function canHaveIllegalModifiers(node: Node): node is HasIllegalModifiers { + const kind = node.kind; + return kind === SyntaxKind.ClassStaticBlockDeclaration + || kind === SyntaxKind.PropertyAssignment + || kind === SyntaxKind.ShorthandPropertyAssignment + || kind === SyntaxKind.FunctionType + || kind === SyntaxKind.MissingDeclaration + || kind === SyntaxKind.NamespaceExportDeclaration; + } + export const isTypeNodeOrTypeParameterDeclaration = or(isTypeNode, isTypeParameterDeclaration) as (node: Node) => node is TypeNode | TypeParameterDeclaration; export const isQuestionOrExclamationToken = or(isQuestionToken, isExclamationToken) as (node: Node) => node is QuestionToken | ExclamationToken; export const isIdentifierOrThisTypeNode = or(isIdentifier, isThisTypeNode) as (node: Node) => node is Identifier | ThisTypeNode; diff --git a/src/compiler/parser.ts b/src/compiler/parser.ts index e57a3fa98f390..018a3ab7bd197 100644 --- a/src/compiler/parser.ts +++ b/src/compiler/parser.ts @@ -69,7 +69,7 @@ namespace ts { } function isAnExternalModuleIndicatorNode(node: Node) { - return hasModifierOfKind(node, SyntaxKind.ExportKeyword) + return canHaveModifiers(node) && hasModifierOfKind(node, SyntaxKind.ExportKeyword) || isImportEqualsDeclaration(node) && isExternalModuleReference(node.moduleReference) || isImportDeclaration(node) || isExportAssignment(node) @@ -87,7 +87,7 @@ namespace ts { } /** Do not use hasModifier inside the parser; it relies on parent pointers. Use this instead. */ - function hasModifierOfKind(node: Node, kind: SyntaxKind) { + function hasModifierOfKind(node: HasModifiers, kind: SyntaxKind) { return some(node.modifiers, m => m.kind === kind); } @@ -117,96 +117,145 @@ namespace ts { return visitNode(cbNode, (node as QualifiedName).left) || visitNode(cbNode, (node as QualifiedName).right); case SyntaxKind.TypeParameter: - return visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as TypeParameterDeclaration).modifiers) || visitNode(cbNode, (node as TypeParameterDeclaration).name) || visitNode(cbNode, (node as TypeParameterDeclaration).constraint) || visitNode(cbNode, (node as TypeParameterDeclaration).default) || visitNode(cbNode, (node as TypeParameterDeclaration).expression); case SyntaxKind.ShorthandPropertyAssignment: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as ShorthandPropertyAssignment).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as ShorthandPropertyAssignment).illegalModifiers) || visitNode(cbNode, (node as ShorthandPropertyAssignment).name) || - visitNode(cbNode, (node as ShorthandPropertyAssignment).questionToken) || - visitNode(cbNode, (node as ShorthandPropertyAssignment).exclamationToken) || + visitNode(cbNode, (node as ShorthandPropertyAssignment).illegalQuestionToken) || + visitNode(cbNode, (node as ShorthandPropertyAssignment).illegalExclamationToken) || visitNode(cbNode, (node as ShorthandPropertyAssignment).equalsToken) || visitNode(cbNode, (node as ShorthandPropertyAssignment).objectAssignmentInitializer); case SyntaxKind.SpreadAssignment: return visitNode(cbNode, (node as SpreadAssignment).expression); case SyntaxKind.Parameter: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as ParameterDeclaration).modifiers) || visitNode(cbNode, (node as ParameterDeclaration).dotDotDotToken) || visitNode(cbNode, (node as ParameterDeclaration).name) || visitNode(cbNode, (node as ParameterDeclaration).questionToken) || visitNode(cbNode, (node as ParameterDeclaration).type) || visitNode(cbNode, (node as ParameterDeclaration).initializer); case SyntaxKind.PropertyDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as PropertyDeclaration).modifiers) || visitNode(cbNode, (node as PropertyDeclaration).name) || visitNode(cbNode, (node as PropertyDeclaration).questionToken) || visitNode(cbNode, (node as PropertyDeclaration).exclamationToken) || visitNode(cbNode, (node as PropertyDeclaration).type) || visitNode(cbNode, (node as PropertyDeclaration).initializer); case SyntaxKind.PropertySignature: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as PropertySignature).modifiers) || visitNode(cbNode, (node as PropertySignature).name) || visitNode(cbNode, (node as PropertySignature).questionToken) || visitNode(cbNode, (node as PropertySignature).type) || - visitNode(cbNode, (node as PropertySignature).initializer); + visitNode(cbNode, (node as PropertySignature).illegalInitializer); case SyntaxKind.PropertyAssignment: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as PropertyAssignment).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as PropertyAssignment).illegalModifiers) || visitNode(cbNode, (node as PropertyAssignment).name) || - visitNode(cbNode, (node as PropertyAssignment).questionToken) || + visitNode(cbNode, (node as PropertyAssignment).illegalQuestionToken) || + visitNode(cbNode, (node as PropertyAssignment).illegalExclamationToken) || visitNode(cbNode, (node as PropertyAssignment).initializer); case SyntaxKind.VariableDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || - visitNode(cbNode, (node as VariableDeclaration).name) || + return visitNode(cbNode, (node as VariableDeclaration).name) || visitNode(cbNode, (node as VariableDeclaration).exclamationToken) || visitNode(cbNode, (node as VariableDeclaration).type) || visitNode(cbNode, (node as VariableDeclaration).initializer); case SyntaxKind.BindingElement: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || - visitNode(cbNode, (node as BindingElement).dotDotDotToken) || + return visitNode(cbNode, (node as BindingElement).dotDotDotToken) || visitNode(cbNode, (node as BindingElement).propertyName) || visitNode(cbNode, (node as BindingElement).name) || visitNode(cbNode, (node as BindingElement).initializer); - case SyntaxKind.FunctionType: + case SyntaxKind.IndexSignature: + return visitNodes(cbNode, cbNodes, (node as IndexSignatureDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as IndexSignatureDeclaration).modifiers) || + visitNodes(cbNode, cbNodes, (node as IndexSignatureDeclaration).typeParameters) || + visitNodes(cbNode, cbNodes, (node as IndexSignatureDeclaration).parameters) || + visitNode(cbNode, (node as IndexSignatureDeclaration).type); case SyntaxKind.ConstructorType: + return visitNodes(cbNode, cbNodes, (node as ConstructorTypeNode).modifiers) || + visitNodes(cbNode, cbNodes, (node as ConstructorTypeNode).typeParameters) || + visitNodes(cbNode, cbNodes, (node as ConstructorTypeNode).parameters) || + visitNode(cbNode, (node as ConstructorTypeNode).type); + case SyntaxKind.FunctionType: + return visitNodes(cbNode, cbNodes, (node as FunctionTypeNode).illegalModifiers) || + visitNodes(cbNode, cbNodes, (node as FunctionTypeNode).typeParameters) || + visitNodes(cbNode, cbNodes, (node as FunctionTypeNode).parameters) || + visitNode(cbNode, (node as FunctionTypeNode).type); case SyntaxKind.CallSignature: case SyntaxKind.ConstructSignature: - case SyntaxKind.IndexSignature: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || - visitNodes(cbNode, cbNodes, (node as SignatureDeclaration).typeParameters) || - visitNodes(cbNode, cbNodes, (node as SignatureDeclaration).parameters) || - visitNode(cbNode, (node as SignatureDeclaration).type); + return visitNodes(cbNode, cbNodes, (node as CallSignatureDeclaration | ConstructSignatureDeclaration).typeParameters) || + visitNodes(cbNode, cbNodes, (node as CallSignatureDeclaration | ConstructSignatureDeclaration).parameters) || + visitNode(cbNode, (node as CallSignatureDeclaration | ConstructSignatureDeclaration).type); case SyntaxKind.MethodDeclaration: + return visitNodes(cbNode, cbNodes, (node as MethodDeclaration).modifiers) || + visitNode(cbNode, (node as MethodDeclaration).asteriskToken) || + visitNode(cbNode, (node as MethodDeclaration).name) || + visitNode(cbNode, (node as MethodDeclaration).questionToken) || + visitNode(cbNode, (node as MethodDeclaration).illegalExclamationToken) || + visitNodes(cbNode, cbNodes, (node as MethodDeclaration).typeParameters) || + visitNodes(cbNode, cbNodes, (node as MethodDeclaration).parameters) || + visitNode(cbNode, (node as MethodDeclaration).type) || + visitNode(cbNode, (node as MethodDeclaration).body); case SyntaxKind.MethodSignature: + return visitNodes(cbNode, cbNodes, (node as MethodSignature).modifiers) || + visitNode(cbNode, (node as MethodSignature).name) || + visitNode(cbNode, (node as MethodSignature).questionToken) || + visitNodes(cbNode, cbNodes, (node as MethodSignature).typeParameters) || + visitNodes(cbNode, cbNodes, (node as MethodSignature).parameters) || + visitNode(cbNode, (node as MethodSignature).type); case SyntaxKind.Constructor: + return visitNodes(cbNode, cbNodes, (node as ConstructorDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as ConstructorDeclaration).modifiers) || + visitNode(cbNode, (node as ConstructorDeclaration).name) || + visitNodes(cbNode, cbNodes, (node as ConstructorDeclaration).illegalTypeParameters) || + visitNodes(cbNode, cbNodes, (node as ConstructorDeclaration).parameters) || + visitNode(cbNode, (node as ConstructorDeclaration).illegalType) || + visitNode(cbNode, (node as ConstructorDeclaration).body); case SyntaxKind.GetAccessor: + return visitNodes(cbNode, cbNodes, (node as GetAccessorDeclaration).modifiers) || + visitNode(cbNode, (node as GetAccessorDeclaration).name) || + visitNodes(cbNode, cbNodes, (node as GetAccessorDeclaration).illegalTypeParameters) || + visitNodes(cbNode, cbNodes, (node as GetAccessorDeclaration).parameters) || + visitNode(cbNode, (node as GetAccessorDeclaration).type) || + visitNode(cbNode, (node as GetAccessorDeclaration).body); case SyntaxKind.SetAccessor: - case SyntaxKind.FunctionExpression: + return visitNodes(cbNode, cbNodes, (node as SetAccessorDeclaration).modifiers) || + visitNode(cbNode, (node as SetAccessorDeclaration).name) || + visitNodes(cbNode, cbNodes, (node as SetAccessorDeclaration).illegalTypeParameters) || + visitNodes(cbNode, cbNodes, (node as SetAccessorDeclaration).parameters) || + visitNode(cbNode, (node as SetAccessorDeclaration).illegalType) || + visitNode(cbNode, (node as SetAccessorDeclaration).body); case SyntaxKind.FunctionDeclaration: + return visitNodes(cbNode, cbNodes, (node as FunctionDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as FunctionDeclaration).modifiers) || + visitNode(cbNode, (node as FunctionDeclaration).asteriskToken) || + visitNode(cbNode, (node as FunctionDeclaration).name) || + visitNodes(cbNode, cbNodes, (node as FunctionDeclaration).typeParameters) || + visitNodes(cbNode, cbNodes, (node as FunctionDeclaration).parameters) || + visitNode(cbNode, (node as FunctionDeclaration).type) || + visitNode(cbNode, (node as FunctionDeclaration).body); + case SyntaxKind.FunctionExpression: + return visitNodes(cbNode, cbNodes, (node as FunctionExpression).modifiers) || + visitNode(cbNode, (node as FunctionExpression).asteriskToken) || + visitNode(cbNode, (node as FunctionExpression).name) || + visitNodes(cbNode, cbNodes, (node as FunctionExpression).typeParameters) || + visitNodes(cbNode, cbNodes, (node as FunctionExpression).parameters) || + visitNode(cbNode, (node as FunctionExpression).type) || + visitNode(cbNode, (node as FunctionExpression).body); case SyntaxKind.ArrowFunction: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || - visitNode(cbNode, (node as FunctionLikeDeclaration).asteriskToken) || - visitNode(cbNode, (node as FunctionLikeDeclaration).name) || - visitNode(cbNode, (node as FunctionLikeDeclaration).questionToken) || - visitNode(cbNode, (node as FunctionLikeDeclaration).exclamationToken) || - visitNodes(cbNode, cbNodes, (node as FunctionLikeDeclaration).typeParameters) || - visitNodes(cbNode, cbNodes, (node as FunctionLikeDeclaration).parameters) || - visitNode(cbNode, (node as FunctionLikeDeclaration).type) || + return visitNodes(cbNode, cbNodes, (node as ArrowFunction).modifiers) || + visitNodes(cbNode, cbNodes, (node as ArrowFunction).typeParameters) || + visitNodes(cbNode, cbNodes, (node as ArrowFunction).parameters) || + visitNode(cbNode, (node as ArrowFunction).type) || visitNode(cbNode, (node as ArrowFunction).equalsGreaterThanToken) || - visitNode(cbNode, (node as FunctionLikeDeclaration).body); + visitNode(cbNode, (node as ArrowFunction).body); case SyntaxKind.ClassStaticBlockDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as ClassStaticBlockDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as ClassStaticBlockDeclaration).illegalModifiers) || visitNode(cbNode, (node as ClassStaticBlockDeclaration).body); case SyntaxKind.TypeReference: return visitNode(cbNode, (node as TypeReferenceNode).typeName) || @@ -333,8 +382,8 @@ namespace ts { return visitNodes(cbNode, cbNodes, (node as SourceFile).statements) || visitNode(cbNode, (node as SourceFile).endOfFileToken); case SyntaxKind.VariableStatement: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as VariableStatement).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as VariableStatement).modifiers) || visitNode(cbNode, (node as VariableStatement).declarationList); case SyntaxKind.VariableDeclarationList: return visitNodes(cbNode, cbNodes, (node as VariableDeclarationList).declarations); @@ -398,46 +447,45 @@ namespace ts { return visitNode(cbNode, (node as Decorator).expression); case SyntaxKind.ClassDeclaration: case SyntaxKind.ClassExpression: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as ClassLikeDeclaration).modifiers) || visitNode(cbNode, (node as ClassLikeDeclaration).name) || visitNodes(cbNode, cbNodes, (node as ClassLikeDeclaration).typeParameters) || visitNodes(cbNode, cbNodes, (node as ClassLikeDeclaration).heritageClauses) || visitNodes(cbNode, cbNodes, (node as ClassLikeDeclaration).members); case SyntaxKind.InterfaceDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as InterfaceDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as InterfaceDeclaration).modifiers) || visitNode(cbNode, (node as InterfaceDeclaration).name) || visitNodes(cbNode, cbNodes, (node as InterfaceDeclaration).typeParameters) || visitNodes(cbNode, cbNodes, (node as ClassDeclaration).heritageClauses) || visitNodes(cbNode, cbNodes, (node as InterfaceDeclaration).members); case SyntaxKind.TypeAliasDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as TypeAliasDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as TypeAliasDeclaration).modifiers) || visitNode(cbNode, (node as TypeAliasDeclaration).name) || visitNodes(cbNode, cbNodes, (node as TypeAliasDeclaration).typeParameters) || visitNode(cbNode, (node as TypeAliasDeclaration).type); case SyntaxKind.EnumDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as EnumDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as EnumDeclaration).modifiers) || visitNode(cbNode, (node as EnumDeclaration).name) || visitNodes(cbNode, cbNodes, (node as EnumDeclaration).members); case SyntaxKind.EnumMember: return visitNode(cbNode, (node as EnumMember).name) || visitNode(cbNode, (node as EnumMember).initializer); case SyntaxKind.ModuleDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as ModuleDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as ModuleDeclaration).modifiers) || visitNode(cbNode, (node as ModuleDeclaration).name) || visitNode(cbNode, (node as ModuleDeclaration).body); case SyntaxKind.ImportEqualsDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as ImportEqualsDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as ImportEqualsDeclaration).modifiers) || visitNode(cbNode, (node as ImportEqualsDeclaration).name) || visitNode(cbNode, (node as ImportEqualsDeclaration).moduleReference); case SyntaxKind.ImportDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as ImportDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as ImportDeclaration).modifiers) || visitNode(cbNode, (node as ImportDeclaration).importClause) || visitNode(cbNode, (node as ImportDeclaration).moduleSpecifier) || visitNode(cbNode, (node as ImportDeclaration).assertClause); @@ -450,7 +498,8 @@ namespace ts { return visitNode(cbNode, (node as AssertEntry).name) || visitNode(cbNode, (node as AssertEntry).value); case SyntaxKind.NamespaceExportDeclaration: - return visitNode(cbNode, (node as NamespaceExportDeclaration).name); + return visitNodes(cbNode, cbNodes, (node as NamespaceExportDeclaration).illegalDecorators) || + visitNode(cbNode, (node as NamespaceExportDeclaration).name); case SyntaxKind.NamespaceImport: return visitNode(cbNode, (node as NamespaceImport).name); case SyntaxKind.NamespaceExport: @@ -459,8 +508,8 @@ namespace ts { case SyntaxKind.NamedExports: return visitNodes(cbNode, cbNodes, (node as NamedImportsOrExports).elements); case SyntaxKind.ExportDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as ExportDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as ExportDeclaration).modifiers) || visitNode(cbNode, (node as ExportDeclaration).exportClause) || visitNode(cbNode, (node as ExportDeclaration).moduleSpecifier) || visitNode(cbNode, (node as ExportDeclaration).assertClause); @@ -469,17 +518,21 @@ namespace ts { return visitNode(cbNode, (node as ImportOrExportSpecifier).propertyName) || visitNode(cbNode, (node as ImportOrExportSpecifier).name); case SyntaxKind.ExportAssignment: - return visitNodes(cbNode, cbNodes, node.decorators) || - visitNodes(cbNode, cbNodes, node.modifiers) || + return visitNodes(cbNode, cbNodes, (node as ExportAssignment).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as ExportAssignment).modifiers) || visitNode(cbNode, (node as ExportAssignment).expression); case SyntaxKind.TemplateExpression: - return visitNode(cbNode, (node as TemplateExpression).head) || visitNodes(cbNode, cbNodes, (node as TemplateExpression).templateSpans); + return visitNode(cbNode, (node as TemplateExpression).head) || + visitNodes(cbNode, cbNodes, (node as TemplateExpression).templateSpans); case SyntaxKind.TemplateSpan: - return visitNode(cbNode, (node as TemplateSpan).expression) || visitNode(cbNode, (node as TemplateSpan).literal); + return visitNode(cbNode, (node as TemplateSpan).expression) || + visitNode(cbNode, (node as TemplateSpan).literal); case SyntaxKind.TemplateLiteralType: - return visitNode(cbNode, (node as TemplateLiteralTypeNode).head) || visitNodes(cbNode, cbNodes, (node as TemplateLiteralTypeNode).templateSpans); + return visitNode(cbNode, (node as TemplateLiteralTypeNode).head) || + visitNodes(cbNode, cbNodes, (node as TemplateLiteralTypeNode).templateSpans); case SyntaxKind.TemplateLiteralTypeSpan: - return visitNode(cbNode, (node as TemplateLiteralTypeSpan).type) || visitNode(cbNode, (node as TemplateLiteralTypeSpan).literal); + return visitNode(cbNode, (node as TemplateLiteralTypeSpan).type) || + visitNode(cbNode, (node as TemplateLiteralTypeSpan).literal); case SyntaxKind.ComputedPropertyName: return visitNode(cbNode, (node as ComputedPropertyName).expression); case SyntaxKind.HeritageClause: @@ -490,7 +543,8 @@ namespace ts { case SyntaxKind.ExternalModuleReference: return visitNode(cbNode, (node as ExternalModuleReference).expression); case SyntaxKind.MissingDeclaration: - return visitNodes(cbNode, cbNodes, node.decorators); + return visitNodes(cbNode, cbNodes, (node as MissingDeclaration).illegalDecorators) || + visitNodes(cbNode, cbNodes, (node as MissingDeclaration).illegalModifiers); case SyntaxKind.CommaListExpression: return visitNodes(cbNode, cbNodes, (node as CommaListExpression).elements); @@ -3137,7 +3191,7 @@ namespace ts { } return finishNode( factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, // TODO(rbuckton): JSDoc parameters don't have names (except `this`/`new`), should we manufacture an empty identifier? @@ -3240,7 +3294,7 @@ namespace ts { isStartOfType(/*inStartOfParameter*/ !isJSDocParameter); } - function parseNameOfParameter(modifiers: ModifiersArray | undefined) { + function parseNameOfParameter(modifiers: NodeArray | undefined) { // FormalParameter [Yield,Await]: // BindingElement[?Yield,?Await] const name = parseIdentifierOrPattern(Diagnostics.Private_identifiers_cannot_be_used_as_parameters); @@ -3287,8 +3341,8 @@ namespace ts { if (token() === SyntaxKind.ThisKeyword) { const node = factory.createParameterDeclaration( + /*decorators*/ RESERVED, decorators, - /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, createIdentifier(/*isIdentifier*/ true), /*questionToken*/ undefined, @@ -3306,7 +3360,7 @@ namespace ts { const savedTopLevel = topLevel; topLevel = false; - const modifiers = parseModifiers(); + const modifiers = combineDecoratorsAndModifiers(decorators, parseModifiers()); const dotDotDotToken = parseOptionalToken(SyntaxKind.DotDotDotToken); if (!allowAmbiguity && !isParameterNameStart()) { @@ -3316,7 +3370,7 @@ namespace ts { const node = withJSDoc( finishNode( factory.createParameterDeclaration( - decorators, + /*decorators*/ RESERVED, modifiers, dotDotDotToken, parseNameOfParameter(modifiers), @@ -3503,7 +3557,8 @@ namespace ts { const parameters = parseBracketedList(ParsingContext.Parameters, () => parseParameter(/*inOuterAwaitContext*/ false), SyntaxKind.OpenBracketToken, SyntaxKind.CloseBracketToken); const type = parseTypeAnnotation(); parseTypeMemberSemicolon(); - const node = factory.createIndexSignature(decorators, modifiers, parameters, type); + const node = factory.createIndexSignature(/*decorators*/ RESERVED, modifiers, parameters, type); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -3525,7 +3580,7 @@ namespace ts { // Although type literal properties cannot not have initializers, we attempt // to parse an initializer so we can report in the checker that an interface // property or type literal property cannot have an initializer. - if (token() === SyntaxKind.EqualsToken) node.initializer = parseInitializer(); + if (token() === SyntaxKind.EqualsToken) node.illegalInitializer = parseInitializer(); } parseTypeMemberSemicolon(); return withJSDoc(finishNode(node, pos), hasJSDoc); @@ -3756,7 +3811,7 @@ namespace ts { const node = isConstructorType ? factory.createConstructorTypeNode(modifiers, typeParameters, parameters, type) : factory.createFunctionTypeNode(typeParameters, parameters, type); - if (!isConstructorType) (node as Mutable).modifiers = modifiers; + if (!isConstructorType) (node as Mutable).illegalModifiers = modifiers; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -4434,7 +4489,7 @@ namespace ts { function parseSimpleArrowFunctionExpression(pos: number, identifier: Identifier, disallowReturnTypeInArrowFunction: boolean, asyncModifier?: NodeArray | undefined): ArrowFunction { Debug.assert(token() === SyntaxKind.EqualsGreaterThanToken, "parseSimpleArrowFunctionExpression should only have been called if we had a =>"); const parameter = factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, identifier, @@ -5879,10 +5934,10 @@ namespace ts { node = factory.createPropertyAssignment(name, initializer); } // Decorators, Modifiers, questionToken, and exclamationToken are not supported by property assignments and are reported in the grammar checker - node.decorators = decorators; - node.modifiers = modifiers; - node.questionToken = questionToken; - node.exclamationToken = exclamationToken; + node.illegalDecorators = decorators; + node.illegalModifiers = modifiers; + node.illegalQuestionToken = questionToken; + node.illegalExclamationToken = exclamationToken; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -6601,8 +6656,8 @@ namespace ts { // would follow. For recovery and error reporting purposes, return an incomplete declaration. const missing = createMissingNode(SyntaxKind.MissingDeclaration, /*reportAtCurrentPosition*/ true, Diagnostics.Declaration_expected); setTextRangePos(missing, pos); - missing.decorators = decorators; - missing.modifiers = modifiers; + missing.illegalDecorators = decorators; + missing.illegalModifiers = modifiers; return missing; } return undefined!; // TODO: GH#18217 @@ -6760,7 +6815,7 @@ namespace ts { parseSemicolon(); const node = factory.createVariableStatement(modifiers, declarationList); // Decorators are not allowed on a variable statement, so we keep track of them to report them in the grammar checker. - node.decorators = decorators; + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -6780,7 +6835,8 @@ namespace ts { const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false); const body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, Diagnostics.or_expected); setAwaitContext(savedAwaitContext); - const node = factory.createFunctionDeclaration(decorators, modifiers, asteriskToken, name, typeParameters, parameters, type, body); + const node = factory.createFunctionDeclaration(/*decorators*/ RESERVED, modifiers, asteriskToken, name, typeParameters, parameters, type, body); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -6803,10 +6859,12 @@ namespace ts { const parameters = parseParameters(SignatureFlags.None); const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false); const body = parseFunctionBlockOrSemicolon(SignatureFlags.None, Diagnostics.or_expected); - const node = factory.createConstructorDeclaration(decorators, modifiers, parameters, body); - // Attach `typeParameters` and `type` if they exist so that we can report them in the grammar checker. - node.typeParameters = typeParameters; - node.type = type; + const node = factory.createConstructorDeclaration(/*decorators*/ RESERVED, modifiers, parameters, body); + + // Attach invalid nodes if they exist so that we can report them in the grammar checker. + node.illegalDecorators = decorators; + node.illegalTypeParameters = typeParameters; + node.illegalType = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } }); @@ -6830,8 +6888,8 @@ namespace ts { const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false); const body = parseFunctionBlockOrSemicolon(isGenerator | isAsync, diagnosticMessage); const node = factory.createMethodDeclaration( - decorators, - modifiers, + /*decorators*/ RESERVED, + combineDecoratorsAndModifiers(decorators, modifiers), asteriskToken, name, questionToken, @@ -6840,8 +6898,9 @@ namespace ts { type, body ); + // An exclamation token on a method is invalid syntax and will be handled by the grammar checker - node.exclamationToken = exclamationToken; + node.illegalExclamationToken = exclamationToken; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -6857,7 +6916,13 @@ namespace ts { const type = parseTypeAnnotation(); const initializer = doOutsideOfContext(NodeFlags.YieldContext | NodeFlags.AwaitContext | NodeFlags.DisallowInContext, parseInitializer); parseSemicolonAfterPropertyName(name, type, initializer); - const node = factory.createPropertyDeclaration(decorators, modifiers, name, questionToken || exclamationToken, type, initializer); + const node = factory.createPropertyDeclaration( + /*decorators*/ RESERVED, + combineDecoratorsAndModifiers(decorators, modifiers), + name, + questionToken || exclamationToken, + type, + initializer); return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -6885,11 +6950,11 @@ namespace ts { const type = parseReturnType(SyntaxKind.ColonToken, /*isType*/ false); const body = parseFunctionBlockOrSemicolon(SignatureFlags.None); const node = kind === SyntaxKind.GetAccessor - ? factory.createGetAccessorDeclaration(decorators, modifiers, name, parameters, type, body) - : factory.createSetAccessorDeclaration(decorators, modifiers, name, parameters, body); + ? factory.createGetAccessorDeclaration(/*decorators*/ RESERVED, combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, type, body) + : factory.createSetAccessorDeclaration(/*decorators*/ RESERVED, combineDecoratorsAndModifiers(decorators, modifiers), name, parameters, body); // Keep track of `typeParameters` (for both) and `type` (for setters) if they were parsed those indicate grammar errors - node.typeParameters = typeParameters; - if (type && node.kind === SyntaxKind.SetAccessor) (node as Mutable).type = type; + node.illegalTypeParameters = typeParameters; + if (isSetAccessorDeclaration(node)) node.illegalType = type; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -6965,7 +7030,10 @@ namespace ts { function parseClassStaticBlockDeclaration(pos: number, hasJSDoc: boolean, decorators: NodeArray | undefined, modifiers: ModifiersArray | undefined): ClassStaticBlockDeclaration { parseExpectedToken(SyntaxKind.StaticKeyword); const body = parseClassStaticBlockBody(); - return withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(decorators, modifiers, body), pos), hasJSDoc); + const node = withJSDoc(finishNode(factory.createClassStaticBlockDeclaration(/*decorators*/ RESERVED, RESERVED, body), pos), hasJSDoc); + node.illegalDecorators = decorators; + node.illegalModifiers = modifiers; + return node; } function parseClassStaticBlockBody() { @@ -7040,6 +7108,14 @@ namespace ts { return finishNode(factory.createToken(kind as Modifier["kind"]), pos); } + function combineDecoratorsAndModifiers(decorators: NodeArray | undefined, modifiers: NodeArray | undefined): NodeArray | undefined { + if (!decorators) return modifiers; + if (!modifiers) return decorators; + const decoratorsAndModifiers = factory.createNodeArray(concatenate(decorators, modifiers)); + setTextRangePosEnd(decoratorsAndModifiers, decorators.pos, modifiers.end); + return decoratorsAndModifiers; + } + /* * There are situations in which a modifier like 'const' will appear unexpectedly, such as on a class member. * In those situations, if we are entirely sure that 'const' is not valid on its own (such as when ASI takes effect @@ -7160,8 +7236,8 @@ namespace ts { } setAwaitContext(savedAwaitContext); const node = kind === SyntaxKind.ClassDeclaration - ? factory.createClassDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members) - : factory.createClassExpression(decorators, modifiers, name, typeParameters, heritageClauses, members); + ? factory.createClassDeclaration(/*decorators*/ RESERVED, combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members) + : factory.createClassExpression(/*decorators*/ RESERVED, combineDecoratorsAndModifiers(decorators, modifiers), name, typeParameters, heritageClauses, members); return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -7229,7 +7305,8 @@ namespace ts { const typeParameters = parseTypeParameters(); const heritageClauses = parseHeritageClauses(); const members = parseObjectTypeMembers(); - const node = factory.createInterfaceDeclaration(decorators, modifiers, name, typeParameters, heritageClauses, members); + const node = factory.createInterfaceDeclaration(/*decorators*/ RESERVED, modifiers, name, typeParameters, heritageClauses, members); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -7240,7 +7317,8 @@ namespace ts { parseExpected(SyntaxKind.EqualsToken); const type = token() === SyntaxKind.IntrinsicKeyword && tryParse(parseKeywordAndNoDot) || parseType(); parseSemicolon(); - const node = factory.createTypeAliasDeclaration(decorators, modifiers, name, typeParameters, type); + const node = factory.createTypeAliasDeclaration(/*decorators*/ RESERVED, modifiers, name, typeParameters, type); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -7267,7 +7345,8 @@ namespace ts { else { members = createMissingList(); } - const node = factory.createEnumDeclaration(decorators, modifiers, name, members); + const node = factory.createEnumDeclaration(/*decorators*/ RESERVED, modifiers, name, members); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -7292,7 +7371,8 @@ namespace ts { const body = parseOptional(SyntaxKind.DotToken) ? parseModuleOrNamespaceDeclaration(getNodePos(), /*hasJSDoc*/ false, /*decorators*/ undefined, /*modifiers*/ undefined, NodeFlags.NestedNamespace | namespaceFlag) as NamespaceDeclaration : parseModuleBlock(); - const node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags); + const node = factory.createModuleDeclaration(/*decorators*/ RESERVED, modifiers, name, body, flags); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -7315,7 +7395,8 @@ namespace ts { else { parseSemicolon(); } - const node = factory.createModuleDeclaration(decorators, modifiers, name, body, flags); + const node = factory.createModuleDeclaration(/*decorators*/ RESERVED, modifiers, name, body, flags); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -7361,8 +7442,8 @@ namespace ts { parseSemicolon(); const node = factory.createNamespaceExportDeclaration(name); // NamespaceExportDeclaration nodes cannot have decorators or modifiers, so we attach them here so we can report them in the grammar checker - node.decorators = decorators; - node.modifiers = modifiers; + node.illegalDecorators = decorators; + node.illegalModifiers = modifiers; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -7409,7 +7490,8 @@ namespace ts { } parseSemicolon(); - const node = factory.createImportDeclaration(decorators, modifiers, importClause, moduleSpecifier, assertClause); + const node = factory.createImportDeclaration(/*decorators*/ RESERVED, modifiers, importClause, moduleSpecifier, assertClause); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -7461,7 +7543,8 @@ namespace ts { parseExpected(SyntaxKind.EqualsToken); const moduleReference = parseModuleReference(); parseSemicolon(); - const node = factory.createImportEqualsDeclaration(decorators, modifiers, isTypeOnly, identifier, moduleReference); + const node = factory.createImportEqualsDeclaration(/*decorators*/ RESERVED, modifiers, isTypeOnly, identifier, moduleReference); + node.illegalDecorators = decorators; const finished = withJSDoc(finishNode(node, pos), hasJSDoc); return finished; } @@ -7669,7 +7752,8 @@ namespace ts { } parseSemicolon(); setAwaitContext(savedAwaitContext); - const node = factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause); + const node = factory.createExportDeclaration(/*decorators*/ RESERVED, modifiers, isTypeOnly, exportClause, moduleSpecifier, assertClause); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -7686,7 +7770,8 @@ namespace ts { const expression = parseAssignmentExpressionOrHigher(/*disallowReturnTypeInArrowFunction*/ false); parseSemicolon(); setAwaitContext(savedAwaitContext); - const node = factory.createExportAssignment(decorators, modifiers, isExportEquals, expression); + const node = factory.createExportAssignment(/*decorators*/ RESERVED, modifiers, isExportEquals, expression); + node.illegalDecorators = decorators; return withJSDoc(finishNode(node, pos), hasJSDoc); } @@ -8536,7 +8621,7 @@ namespace ts { if (parseOptional(SyntaxKind.DotToken)) { const body = parseJSDocTypeNameWithNamespace(/*nested*/ true); const jsDocNamespaceNode = factory.createModuleDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, typeNameOrNamespaceName, body, diff --git a/src/compiler/program.ts b/src/compiler/program.ts index c7f886ea3119f..977dfaaf8b0ae 100644 --- a/src/compiler/program.ts +++ b/src/compiler/program.ts @@ -2340,7 +2340,7 @@ namespace ts { } function walkArray(nodes: NodeArray, parent: Node) { - if (parent.decorators === nodes && !options.experimentalDecorators) { + if (canHaveModifiers(parent) && parent.modifiers === nodes && some(nodes, isDecorator) && !options.experimentalDecorators) { diagnostics.push(createDiagnosticForNode(parent, Diagnostics.Experimental_support_for_decorators_is_a_feature_that_is_subject_to_change_in_a_future_release_Set_the_experimentalDecorators_option_in_your_tsconfig_or_jsconfig_to_remove_this_warning)); } @@ -2363,16 +2363,16 @@ namespace ts { case SyntaxKind.VariableStatement: // Check modifiers - if (nodes === parent.modifiers) { - checkModifiers(parent.modifiers, parent.kind === SyntaxKind.VariableStatement); + if (nodes === (parent as VariableStatement).modifiers) { + checkModifiers((parent as VariableStatement).modifiers!, parent.kind === SyntaxKind.VariableStatement); return "skip"; } break; case SyntaxKind.PropertyDeclaration: // Check modifiers of property declaration if (nodes === (parent as PropertyDeclaration).modifiers) { - for (const modifier of nodes as NodeArray) { - if (modifier.kind !== SyntaxKind.StaticKeyword) { + for (const modifier of nodes as NodeArray) { + if (isModifier(modifier) && modifier.kind !== SyntaxKind.StaticKeyword) { diagnostics.push(createDiagnosticForNode(modifier, Diagnostics.The_0_modifier_can_only_be_used_in_TypeScript_files, tokenToString(modifier.kind))); } } @@ -2381,7 +2381,7 @@ namespace ts { break; case SyntaxKind.Parameter: // Check modifiers of parameter declaration - if (nodes === (parent as ParameterDeclaration).modifiers) { + if (nodes === (parent as ParameterDeclaration).modifiers && some(nodes, isModifier)) { diagnostics.push(createDiagnosticForNodeArray(nodes, Diagnostics.Parameter_modifiers_can_only_be_used_in_TypeScript_files)); return "skip"; } @@ -2401,7 +2401,7 @@ namespace ts { } } - function checkModifiers(modifiers: NodeArray, isConstValid: boolean) { + function checkModifiers(modifiers: NodeArray, isConstValid: boolean) { for (const modifier of modifiers) { switch (modifier.kind) { case SyntaxKind.ConstKeyword: @@ -2523,7 +2523,7 @@ namespace ts { function createSyntheticImport(text: string, file: SourceFile) { const externalHelpersModuleReference = factory.createStringLiteral(text); - const importDecl = factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); + const importDecl = factory.createImportDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*importClause*/ undefined, externalHelpersModuleReference, /*assertClause*/ undefined); addEmitFlags(importDecl, EmitFlags.NeverApplyImportHelper); setParent(externalHelpersModuleReference, importDecl); setParent(importDecl, file); diff --git a/src/compiler/transformers/classFields.ts b/src/compiler/transformers/classFields.ts index cff2be7fb78b8..f5fec571feea2 100644 --- a/src/compiler/transformers/classFields.ts +++ b/src/compiler/transformers/classFields.ts @@ -366,7 +366,7 @@ namespace ts { } function visitMethodOrAccessorDeclaration(node: MethodDeclaration | AccessorDeclaration) { - Debug.assert(!some(node.decorators)); + Debug.assert(!hasDecorators(node)); if (!shouldTransformPrivateElementsOrClassStaticBlocks || !isPrivateIdentifier(node.name)) { return visitEachChild(node, classElementVisitor, context); @@ -385,7 +385,7 @@ namespace ts { factory.createAssignment( functionName, factory.createFunctionExpression( - filter(node.modifiers, m => !isStaticModifier(m)), + filter(node.modifiers, (m): m is Modifier => isModifier(m) && !isStaticModifier(m)), node.asteriskToken, functionName, /* typeParameters */ undefined, @@ -421,7 +421,7 @@ namespace ts { } function visitPropertyDeclaration(node: PropertyDeclaration) { - Debug.assert(!some(node.decorators)); + Debug.assert(!hasDecorators(node)); if (isPrivateIdentifier(node.name)) { if (!shouldTransformPrivateElementsOrClassStaticBlocks) { @@ -433,8 +433,8 @@ namespace ts { // Initializer is elided as the field is initialized in transformConstructor. return factory.updatePropertyDeclaration( node, - /*decorators*/ undefined, - visitNodes(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + visitNodes(node.modifiers, visitor, isModifierLike), node.name, /*questionOrExclamationToken*/ undefined, /*type*/ undefined, @@ -461,8 +461,8 @@ namespace ts { const initializerStatement = transformPropertyOrClassStaticBlock(node, factory.createThis()); if (initializerStatement) { const staticBlock = factory.createClassStaticBlockDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, + /*decorators*/ RESERVED, + /*modifiers*/ RESERVED, factory.createBlock([initializerStatement]) ); @@ -1051,7 +1051,7 @@ namespace ts { const statements: Statement[] = [ factory.updateClassDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, node.modifiers, node.name, /*typeParameters*/ undefined, @@ -1123,8 +1123,8 @@ namespace ts { const classExpression = factory.updateClassExpression( node, - visitNodes(node.decorators, visitor, isDecorator), - node.modifiers, + /*decorators*/ RESERVED, + visitNodes(node.modifiers, visitor, isModifierLike), node.name, /*typeParameters*/ undefined, visitNodes(node.heritageClauses, heritageClauseVisitor, isHeritageClause), @@ -1208,8 +1208,8 @@ namespace ts { if (!shouldTransformPrivateElementsOrClassStaticBlocks && some(pendingExpressions)) { members.push(factory.createClassStaticBlockDeclaration( - /*decorators*/ undefined, - /*modifiers*/ undefined, + /*decorators*/ RESERVED, + /*modifiers*/ RESERVED, factory.createBlock([ factory.createExpressionStatement(factory.inlineExpressions(pendingExpressions)) ]) @@ -1265,7 +1265,7 @@ namespace ts { setOriginalNode( setTextRange( factory.createConstructorDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, parameters ?? [], body diff --git a/src/compiler/transformers/declarations.ts b/src/compiler/transformers/declarations.ts index 3a3e237c5ea5e..85a95d7a96597 100644 --- a/src/compiler/transformers/declarations.ts +++ b/src/compiler/transformers/declarations.ts @@ -280,7 +280,7 @@ namespace ts { needsDeclare = false; const statements = isSourceFileJS(sourceFile) ? factory.createNodeArray(transformDeclarationsForJS(sourceFile, /*bundled*/ true)) : visitNodes(sourceFile.statements, visitDeclarationStatements); const newFile = factory.updateSourceFile(sourceFile, [factory.createModuleDeclaration( - [], + /*decorators*/ RESERVED, [factory.createModifier(SyntaxKind.DeclareKeyword)], factory.createStringLiteral(getResolvedExternalModuleName(context.getEmitHost(), sourceFile)), factory.createModuleBlock(setTextRange(factory.createNodeArray(transformAndReplaceLatePaintedStatements(statements)), sourceFile.statements)) @@ -477,7 +477,7 @@ namespace ts { } const newParam = factory.updateParameterDeclaration( p, - /*decorators*/ undefined, + /*decorators*/ RESERVED, maskModifiers(p, modifierMask), p.dotDotDotToken, filterBindingPatternInitializers(p.name), @@ -551,7 +551,7 @@ namespace ts { if (node.kind === SyntaxKind.Parameter || node.kind === SyntaxKind.PropertyDeclaration || node.kind === SyntaxKind.PropertySignature) { - if (!node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); + if (isPropertySignature(node) || !node.initializer) return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType)); return cleanup(resolver.createTypeOfDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker, shouldUseResolverType) || resolver.createTypeOfExpression(node.initializer, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); } return cleanup(resolver.createReturnTypeOfSignatureDeclaration(node, enclosingDeclaration, declarationEmitNodeBuilderFlags, symbolTracker)); @@ -642,7 +642,7 @@ namespace ts { } if (!newValueParameter) { newValueParameter = factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "value" @@ -708,7 +708,7 @@ namespace ts { const specifier = getExternalModuleImportEqualsDeclarationExpression(decl); return factory.updateImportEqualsDeclaration( decl, - /*decorators*/ undefined, + /*decorators*/ RESERVED, decl.modifiers, decl.isTypeOnly, decl.name, @@ -729,7 +729,7 @@ namespace ts { // import "mod" - possibly needed for side effects? (global interface patches, module augmentations, etc) return factory.updateImportDeclaration( decl, - /*decorators*/ undefined, + /*decorators*/ RESERVED, decl.modifiers, decl.importClause, rewriteModuleSpecifier(decl, decl.moduleSpecifier), @@ -740,7 +740,7 @@ namespace ts { const visibleDefaultBinding = decl.importClause && decl.importClause.name && resolver.isDeclarationVisible(decl.importClause) ? decl.importClause.name : undefined; if (!decl.importClause.namedBindings) { // No named bindings (either namespace or list), meaning the import is just default or should be elided - return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause( + return visibleDefaultBinding && factory.updateImportDeclaration(decl, /*decorators*/ RESERVED, decl.modifiers, factory.updateImportClause( decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, @@ -750,7 +750,7 @@ namespace ts { if (decl.importClause.namedBindings.kind === SyntaxKind.NamespaceImport) { // Namespace import (optionally with visible default) const namedBindings = resolver.isDeclarationVisible(decl.importClause.namedBindings) ? decl.importClause.namedBindings : /*namedBindings*/ undefined; - return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ undefined, decl.modifiers, factory.updateImportClause( + return visibleDefaultBinding || namedBindings ? factory.updateImportDeclaration(decl, /*decorators*/ RESERVED, decl.modifiers, factory.updateImportClause( decl.importClause, decl.importClause.isTypeOnly, visibleDefaultBinding, @@ -762,7 +762,7 @@ namespace ts { if ((bindingList && bindingList.length) || visibleDefaultBinding) { return factory.updateImportDeclaration( decl, - /*decorators*/ undefined, + /*decorators*/ RESERVED, decl.modifiers, factory.updateImportClause( decl.importClause, @@ -778,7 +778,7 @@ namespace ts { if (resolver.isImportRequiredByAugmentation(decl)) { return factory.updateImportDeclaration( decl, - /*decorators*/ undefined, + /*decorators*/ RESERVED, decl.modifiers, /*importClause*/ undefined, rewriteModuleSpecifier(decl, decl.moduleSpecifier), @@ -873,7 +873,7 @@ namespace ts { if (isMethodDeclaration(input) || isMethodSignature(input)) { if (hasEffectiveModifier(input, ModifierFlags.Private)) { if (input.symbol && input.symbol.declarations && input.symbol.declarations[0] !== input) return; // Elide all but the first overload - return cleanup(factory.createPropertyDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); + return cleanup(factory.createPropertyDeclaration(/*decorators*/ RESERVED, ensureModifiers(input), input.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); } } @@ -914,7 +914,7 @@ namespace ts { case SyntaxKind.Constructor: { // A constructor declaration may not have a type annotation const ctor = factory.createConstructorDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ ensureModifiers(input), updateParamsList(input, input.parameters, ModifierFlags.None), /*body*/ undefined @@ -926,7 +926,7 @@ namespace ts { return cleanup(/*returnValue*/ undefined); } const sig = factory.createMethodDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, @@ -945,7 +945,7 @@ namespace ts { const accessorType = getTypeAnnotationFromAllAccessorDeclarations(input, resolver.getAllAccessorDeclarations(input)); return cleanup(factory.updateGetAccessorDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, ensureModifiers(input), input.name, updateAccessorParamsList(input, hasEffectiveModifier(input, ModifierFlags.Private)), @@ -958,7 +958,7 @@ namespace ts { } return cleanup(factory.updateSetAccessorDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, ensureModifiers(input), input.name, updateAccessorParamsList(input, hasEffectiveModifier(input, ModifierFlags.Private)), @@ -970,7 +970,7 @@ namespace ts { } return cleanup(factory.updatePropertyDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, ensureModifiers(input), input.name, input.questionToken, @@ -1013,7 +1013,7 @@ namespace ts { case SyntaxKind.IndexSignature: { return cleanup(factory.updateIndexSignature( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, ensureModifiers(input), updateParamsList(input, input.parameters), visitNode(input.type, visitDeclarationSubtree) || factory.createKeywordTypeNode(SyntaxKind.AnyKeyword) @@ -1113,7 +1113,7 @@ namespace ts { // Rewrite external module names if necessary return factory.updateExportDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, input.modifiers, input.isTypeOnly, input.exportClause, @@ -1140,7 +1140,7 @@ namespace ts { const varDecl = factory.createVariableDeclaration(newId, /*exclamationToken*/ undefined, resolver.createTypeOfExpression(input.expression, input, declarationEmitNodeBuilderFlags, symbolTracker), /*initializer*/ undefined); errorFallbackNode = undefined; const statement = factory.createVariableStatement(needsDeclare ? [factory.createModifier(SyntaxKind.DeclareKeyword)] : [], factory.createVariableDeclarationList([varDecl], NodeFlags.Const)); - return [statement, factory.updateExportAssignment(input, input.decorators, input.modifiers, newId)]; + return [statement, factory.updateExportAssignment(input, /*decorators*/ RESERVED, input.modifiers, newId)]; } } } @@ -1197,7 +1197,7 @@ namespace ts { case SyntaxKind.TypeAliasDeclaration: // Type aliases get `declare`d if need be (for legacy support), but that's all return cleanup(factory.updateTypeAliasDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, ensureModifiers(input), input.name, visitNodes(input.typeParameters, visitDeclarationSubtree, isTypeParameterDeclaration), @@ -1206,7 +1206,7 @@ namespace ts { case SyntaxKind.InterfaceDeclaration: { return cleanup(factory.updateInterfaceDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, ensureModifiers(input), input.name, ensureTypeParams(input, input.typeParameters), @@ -1218,7 +1218,7 @@ namespace ts { // Generators lose their generator-ness, excepting their return type const clean = cleanup(factory.updateFunctionDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, ensureModifiers(input), /*asteriskToken*/ undefined, input.name, @@ -1230,7 +1230,7 @@ namespace ts { if (clean && resolver.isExpandoFunctionDeclaration(input) && shouldEmitFunctionProperties(input)) { const props = resolver.getPropertiesOfContainerFunction(input); // Use parseNodeFactory so it is usable as an enclosing declaration - const fakespace = parseNodeFactory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), NodeFlags.Namespace); + const fakespace = parseNodeFactory.createModuleDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, clean.name || factory.createIdentifier("_default"), factory.createModuleBlock([]), NodeFlags.Namespace); setParent(fakespace, enclosingDeclaration as SourceFile | NamespaceDeclaration); fakespace.locals = createSymbolTable(props); fakespace.symbol = props[0].parent!; @@ -1256,7 +1256,7 @@ namespace ts { } else { declarations.push(factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports(map(exportMappings, ([gen, exp]) => { @@ -1264,7 +1264,7 @@ namespace ts { })) )); } - const namespaceDecl = factory.createModuleDeclaration(/*decorators*/ undefined, ensureModifiers(input), input.name!, factory.createModuleBlock(declarations), NodeFlags.Namespace); + const namespaceDecl = factory.createModuleDeclaration(/*decorators*/ RESERVED, ensureModifiers(input), input.name!, factory.createModuleBlock(declarations), NodeFlags.Namespace); if (!hasEffectiveModifier(clean, ModifierFlags.Default)) { return [clean, namespaceDecl]; } @@ -1272,7 +1272,7 @@ namespace ts { const modifiers = factory.createModifiersFromModifierFlags((getEffectiveModifierFlags(clean) & ~ModifierFlags.ExportDefault) | ModifierFlags.Ambient); const cleanDeclaration = factory.updateFunctionDeclaration( clean, - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, /*asteriskToken*/ undefined, clean.name, @@ -1284,14 +1284,14 @@ namespace ts { const namespaceDeclaration = factory.updateModuleDeclaration( namespaceDecl, - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, namespaceDecl.name, namespaceDecl.body ); const exportDefaultDeclaration = factory.createExportAssignment( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isExportEquals*/ false, namespaceDecl.name @@ -1340,7 +1340,7 @@ namespace ts { const mods = ensureModifiers(input); return cleanup(factory.updateModuleDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, mods, isExternalModuleAugmentation(input) ? rewriteModuleSpecifier(input, input.name) : input.name, body @@ -1357,7 +1357,7 @@ namespace ts { lateStatementReplacementMap.delete(id); return cleanup(factory.updateModuleDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, mods, input.name, body as ModuleBody @@ -1378,7 +1378,7 @@ namespace ts { getSymbolAccessibilityDiagnostic = createGetSymbolAccessibilityDiagnosticForNode(param); if (param.name.kind === SyntaxKind.Identifier) { return preserveJsDoc(factory.createPropertyDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, ensureModifiers(param), param.name, param.questionToken, @@ -1399,7 +1399,7 @@ namespace ts { } elems = elems || []; elems.push(factory.createPropertyDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, ensureModifiers(param), elem.name as Identifier, /*questionToken*/ undefined, @@ -1418,7 +1418,7 @@ namespace ts { // Prevents other classes with the same public members from being used in place of the current class const privateIdentifier = hasPrivateIdentifier ? [ factory.createPropertyDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createPrivateIdentifier("#private"), /*questionToken*/ undefined, @@ -1454,7 +1454,7 @@ namespace ts { })); return [statement, cleanup(factory.updateClassDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, input.name, typeParameters, @@ -1466,7 +1466,7 @@ namespace ts { const heritageClauses = transformHeritageClauses(input.heritageClauses); return cleanup(factory.updateClassDeclaration( input, - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, input.name, typeParameters, @@ -1479,7 +1479,7 @@ namespace ts { return cleanup(transformVariableStatement(input)); } case SyntaxKind.EnumDeclaration: { - return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ undefined, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(mapDefined(input.members, m => { + return cleanup(factory.updateEnumDeclaration(input, /*decorators*/ RESERVED, factory.createNodeArray(ensureModifiers(input)), input.name, factory.createNodeArray(mapDefined(input.members, m => { if (shouldStripInternal(m)) return; // Rewrite enum values to their constants, if available const constValue = resolver.getConstantValue(m); @@ -1564,11 +1564,11 @@ namespace ts { return some(statements, isScopeMarker); } - function ensureModifiers(node: Node): readonly Modifier[] | undefined { + function ensureModifiers(node: T): readonly NonNullable[number][] | undefined { const currentFlags = getEffectiveModifierFlags(node); const newFlags = ensureModifierFlags(node); if (currentFlags === newFlags) { - return node.modifiers; + return visitNodes(node.modifiers, n => tryCast(n, isModifier), isModifier); } return factory.createModifiersFromModifierFlags(newFlags); } diff --git a/src/compiler/transformers/es2015.ts b/src/compiler/transformers/es2015.ts index 38ad28faacc32..71665f73f0834 100644 --- a/src/compiler/transformers/es2015.ts +++ b/src/compiler/transformers/es2015.ts @@ -819,7 +819,7 @@ namespace ts { /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, - extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel))] : [], + extendsClauseElement ? [factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createUniqueName("_super", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel))] : [], /*type*/ undefined, transformClassBody(node, extendsClauseElement) ); @@ -922,7 +922,7 @@ namespace ts { const constructor = getFirstConstructorWithBody(node); const hasSynthesizedSuper = hasSynthesizedDefaultSuperCall(constructor, extendsClauseElement !== undefined); const constructorFunction = factory.createFunctionDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*asteriskToken*/ undefined, name, @@ -1243,7 +1243,7 @@ namespace ts { return setOriginalNode( setTextRange( factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.getGeneratedNameForNode(node), @@ -1261,7 +1261,7 @@ namespace ts { return setOriginalNode( setTextRange( factory.createParameterDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, node.name, @@ -1905,7 +1905,7 @@ namespace ts { convertedLoopState = savedConvertedLoopState; return factory.updateFunctionDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, visitNodes(node.modifiers, visitor, isModifier), node.asteriskToken, name, @@ -3446,7 +3446,7 @@ namespace ts { } } else { - loopParameters.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); + loopParameters.push(factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, name)); const checkFlags = resolver.getNodeCheckFlags(decl); if (checkFlags & NodeCheckFlags.NeedsLoopOutParameter || hasCapturedBindingsInForHead) { const outParamName = factory.createUniqueName("out_" + idText(name)); @@ -3649,10 +3649,10 @@ namespace ts { const parameters = visitParameterList(node.parameters, visitor, context); const body = transformFunctionBody(node); if (node.kind === SyntaxKind.GetAccessor) { - updated = factory.updateGetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, node.type, body); + updated = factory.updateGetAccessorDeclaration(node, /*decorators*/ RESERVED, node.modifiers, node.name, parameters, node.type, body); } else { - updated = factory.updateSetAccessorDeclaration(node, node.decorators, node.modifiers, node.name, parameters, body); + updated = factory.updateSetAccessorDeclaration(node, /*decorators*/ RESERVED, node.modifiers, node.name, parameters, body); } exitSubtree(ancestorFacts, HierarchyFacts.FunctionSubtreeExcludes, HierarchyFacts.None); convertedLoopState = savedConvertedLoopState; diff --git a/src/compiler/transformers/es2017.ts b/src/compiler/transformers/es2017.ts index 50c4fa62c0dcb..9ce7fd3d38821 100644 --- a/src/compiler/transformers/es2017.ts +++ b/src/compiler/transformers/es2017.ts @@ -289,8 +289,8 @@ namespace ts { function visitMethodDeclaration(node: MethodDeclaration) { return factory.updateMethodDeclaration( node, - /*decorators*/ undefined, - visitNodes(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + visitNodes(node.modifiers, visitor, isModifierLike), node.asteriskToken, node.name, /*questionToken*/ undefined, @@ -314,8 +314,8 @@ namespace ts { function visitFunctionDeclaration(node: FunctionDeclaration): VisitResult { return factory.updateFunctionDeclaration( node, - /*decorators*/ undefined, - visitNodes(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + visitNodes(node.modifiers, visitor, isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, @@ -338,7 +338,7 @@ namespace ts { function visitFunctionExpression(node: FunctionExpression): Expression { return factory.updateFunctionExpression( node, - visitNodes(node.modifiers, visitor, isModifier), + visitNodes(node.modifiers, visitor, isModifierLike), node.asteriskToken, node.name, /*typeParameters*/ undefined, @@ -361,7 +361,7 @@ namespace ts { function visitArrowFunction(node: ArrowFunction) { return factory.updateArrowFunction( node, - visitNodes(node.modifiers, visitor, isModifier), + visitNodes(node.modifiers, visitor, isModifierLike), /*typeParameters*/ undefined, visitParameterList(node.parameters, visitor, context), /*type*/ undefined, @@ -764,7 +764,7 @@ namespace ts { /* typeParameters */ undefined, /* parameters */ [ factory.createParameterDeclaration( - /* decorators */ undefined, + /*decorators*/ RESERVED, /* modifiers */ undefined, /* dotDotDotToken */ undefined, "v", diff --git a/src/compiler/transformers/es2018.ts b/src/compiler/transformers/es2018.ts index e3923c79d9fc3..7e7f4b110a6b1 100644 --- a/src/compiler/transformers/es2018.ts +++ b/src/compiler/transformers/es2018.ts @@ -796,7 +796,7 @@ namespace ts { if (parametersWithPrecedingObjectRestOrSpread?.has(node)) { return factory.updateParameterDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, node.dotDotDotToken, isBindingPattern(node.name) ? factory.getGeneratedNameForNode(node) : node.name, @@ -810,7 +810,7 @@ namespace ts { // evaluated inside the function body. return factory.updateParameterDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, node.dotDotDotToken, factory.getGeneratedNameForNode(node), @@ -842,7 +842,7 @@ namespace ts { parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); const updated = factory.updateConstructorDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, node.modifiers, visitParameterList(node.parameters, parameterVisitor, context), transformFunctionBody(node) @@ -859,7 +859,7 @@ namespace ts { parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); const updated = factory.updateGetAccessorDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, node.modifiers, visitNode(node.name, visitor, isPropertyName), visitParameterList(node.parameters, parameterVisitor, context), @@ -878,7 +878,7 @@ namespace ts { parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); const updated = factory.updateSetAccessorDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, node.modifiers, visitNode(node.name, visitor, isPropertyName), visitParameterList(node.parameters, parameterVisitor, context), @@ -896,9 +896,9 @@ namespace ts { parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); const updated = factory.updateMethodDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, enclosingFunctionFlags & FunctionFlags.Generator - ? visitNodes(node.modifiers, visitorNoAsyncModifier, isModifier) + ? visitNodes(node.modifiers, visitorNoAsyncModifier, isModifierLike) : node.modifiers, enclosingFunctionFlags & FunctionFlags.Async ? undefined @@ -924,7 +924,7 @@ namespace ts { parametersWithPrecedingObjectRestOrSpread = collectParametersWithPrecedingObjectRestOrSpread(node); const updated = factory.updateFunctionDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, enclosingFunctionFlags & FunctionFlags.Generator ? visitNodes(node.modifiers, visitorNoAsyncModifier, isModifier) : node.modifiers, diff --git a/src/compiler/transformers/generators.ts b/src/compiler/transformers/generators.ts index 73e35b4583d0e..92039a73b737b 100644 --- a/src/compiler/transformers/generators.ts +++ b/src/compiler/transformers/generators.ts @@ -451,7 +451,7 @@ namespace ts { node = setOriginalNode( setTextRange( factory.createFunctionDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, node.modifiers, /*asteriskToken*/ undefined, node.name, @@ -2064,7 +2064,7 @@ namespace ts { * Gets the current open block. */ function peekBlock() { - return lastOrUndefined(blockStack!); + return lastOrUndefined(blockStack); } /** @@ -2658,7 +2658,7 @@ namespace ts { /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, - [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], + [factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, state)], /*type*/ undefined, factory.createBlock( buildResult, diff --git a/src/compiler/transformers/jsx.ts b/src/compiler/transformers/jsx.ts index d321e74817bd4..ac744a9150b17 100644 --- a/src/compiler/transformers/jsx.ts +++ b/src/compiler/transformers/jsx.ts @@ -85,7 +85,7 @@ namespace ts { for (const [importSource, importSpecifiersMap] of arrayFrom(currentFileState.utilizedImplicitRuntimeImports.entries())) { if (isExternalModule(node)) { // Add `import` statement - const importStatement = factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause(/*typeOnly*/ false, /*name*/ undefined, factory.createNamedImports(arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource), /*assertClause*/ undefined); + const importStatement = factory.createImportDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createImportClause(/*typeOnly*/ false, /*name*/ undefined, factory.createNamedImports(arrayFrom(importSpecifiersMap.values()))), factory.createStringLiteral(importSource), /*assertClause*/ undefined); setParentRecursive(importStatement, /*incremental*/ false); statements = insertStatementAfterCustomPrologue(statements.slice(), importStatement); } diff --git a/src/compiler/transformers/module/esnextAnd2015.ts b/src/compiler/transformers/module/esnextAnd2015.ts index 5e755e5083cb3..53998669ad9b3 100644 --- a/src/compiler/transformers/module/esnextAnd2015.ts +++ b/src/compiler/transformers/module/esnextAnd2015.ts @@ -98,7 +98,7 @@ namespace ts { if (!importRequireStatements) { const createRequireName = factory.createUniqueName("_createRequire", GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); const importStatement = factory.createImportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createImportClause( /*isTypeOnly*/ false, @@ -174,7 +174,7 @@ namespace ts { function appendExportsOfImportEqualsDeclaration(statements: Statement[] | undefined, node: ImportEqualsDeclaration) { if (hasSyntacticModifier(node, ModifierFlags.Export)) { statements = append(statements, factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, node.isTypeOnly, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, /*propertyName*/ undefined, idText(node.name))]) @@ -202,7 +202,7 @@ namespace ts { const oldIdentifier = node.exportClause.name; const synthName = factory.getGeneratedNameForNode(oldIdentifier); const importDecl = factory.createImportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, factory.createImportClause( /*isTypeOnly*/ false, @@ -217,7 +217,7 @@ namespace ts { setOriginalNode(importDecl, node.exportClause); const exportDecl = isExportNamespaceAsDefaultDeclaration(node) ? factory.createExportDefault(synthName) : factory.createExportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([factory.createExportSpecifier(/*isTypeOnly*/ false, synthName, oldIdentifier)]), diff --git a/src/compiler/transformers/module/module.ts b/src/compiler/transformers/module/module.ts index 2b4978306e88a..3b0096876a52e 100644 --- a/src/compiler/transformers/module/module.ts +++ b/src/compiler/transformers/module/module.ts @@ -193,8 +193,8 @@ namespace ts { /*name*/ undefined, /*typeParameters*/ undefined, [ - factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), - factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports"), + factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports"), ...importAliasNames ], /*type*/ undefined, @@ -225,7 +225,7 @@ namespace ts { /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, - [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], + [factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "factory")], /*type*/ undefined, setTextRange( factory.createBlock( @@ -333,8 +333,8 @@ namespace ts { /*name*/ undefined, /*typeParameters*/ undefined, [ - factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), - factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports"), + factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "require"), + factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "exports"), ...importAliasNames ], /*type*/ undefined, @@ -374,7 +374,7 @@ namespace ts { for (const amdDependency of node.amdDependencies) { if (amdDependency.name) { aliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)); - importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); + importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, amdDependency.name)); } else { unaliasedModuleNames.push(factory.createStringLiteral(amdDependency.path)); @@ -396,7 +396,7 @@ namespace ts { // This is so that when printer will not substitute the identifier setEmitFlags(importAliasName, EmitFlags.NoSubstitution); aliasedModuleNames.push(externalModuleName); - importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); + importAliasNames.push(factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, importAliasName)); } else { unaliasedModuleNames.push(externalModuleName); @@ -772,8 +772,8 @@ namespace ts { const resolve = factory.createUniqueName("resolve"); const reject = factory.createUniqueName("reject"); const parameters = [ - factory.createParameterDeclaration(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ resolve), - factory.createParameterDeclaration(/*decorator*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) + factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ resolve), + factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ reject) ]; const body = factory.createBlock([ factory.createExpressionStatement( @@ -1228,7 +1228,7 @@ namespace ts { setOriginalNode( setTextRange( factory.createFunctionDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, visitNodes(node.modifiers, modifierVisitor, isModifier), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), @@ -1271,8 +1271,8 @@ namespace ts { setOriginalNode( setTextRange( factory.createClassDeclaration( - /*decorators*/ undefined, - visitNodes(node.modifiers, modifierVisitor, isModifier), + /*decorators*/ RESERVED, + visitNodes(node.modifiers, modifierVisitor, isModifierLike), factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, visitNodes(node.heritageClauses, visitor), diff --git a/src/compiler/transformers/module/system.ts b/src/compiler/transformers/module/system.ts index 14216e5cab63f..e73a481ee6eec 100644 --- a/src/compiler/transformers/module/system.ts +++ b/src/compiler/transformers/module/system.ts @@ -87,8 +87,8 @@ namespace ts { /*name*/ undefined, /*typeParameters*/ undefined, [ - factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, exportFunction), - factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, contextObject) + factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, exportFunction), + factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, contextObject) ], /*type*/ undefined, moduleBodyBlock @@ -385,12 +385,12 @@ namespace ts { } return factory.createFunctionDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*asteriskToken*/ undefined, exportStarFunction, /*typeParameters*/ undefined, - [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, m)], + [factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, m)], /*type*/ undefined, factory.createBlock([ factory.createVariableStatement( @@ -545,7 +545,7 @@ namespace ts { /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, - [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], + [factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, factory.createBlock(statements, /*multiLine*/ true) ) @@ -667,8 +667,8 @@ namespace ts { hoistedStatements = append(hoistedStatements, factory.updateFunctionDeclaration( node, - node.decorators, - visitNodes(node.modifiers, modifierVisitor, isModifier), + /*decorators*/ RESERVED, + visitNodes(node.modifiers, modifierVisitor, isModifierLike), node.asteriskToken, factory.getDeclarationName(node, /*allowComments*/ true, /*allowSourceMaps*/ true), /*typeParameters*/ undefined, @@ -712,8 +712,8 @@ namespace ts { name, setTextRange( factory.createClassExpression( - visitNodes(node.decorators, visitor, isDecorator), - /*modifiers*/ undefined, + /*decorators*/ RESERVED, + visitNodes(node.modifiers, modifierVisitor, isModifierLike), node.name, /*typeParameters*/ undefined, visitNodes(node.heritageClauses, visitor, isHeritageClause), diff --git a/src/compiler/transformers/ts.ts b/src/compiler/transformers/ts.ts index bcb92d9594a8a..81d88085f1d27 100644 --- a/src/compiler/transformers/ts.ts +++ b/src/compiler/transformers/ts.ts @@ -337,6 +337,7 @@ namespace ts { } function modifierVisitor(node: Node): VisitResult { + if (isDecorator(node)) return undefined; if (modifierToFlag(node.kind) & ModifierFlags.TypeScriptModifier) { return undefined; } @@ -588,7 +589,7 @@ namespace ts { } function isClassLikeDeclarationWithTypeScriptSyntax(node: ClassLikeDeclaration) { - return some(node.decorators) + return hasDecorators(node) || some(node.typeParameters) || some(node.heritageClauses, hasTypeScriptClassSyntax) || some(node.members, hasTypeScriptClassSyntax); @@ -707,11 +708,11 @@ namespace ts { // we do not emit modifiers on the declaration if we are emitting an IIFE const modifiers = !(facts & ClassFacts.UseImmediatelyInvokedFunctionExpression) - ? visitNodes(node.modifiers, modifierVisitor, isModifier) + ? visitNodes(node.modifiers, modifierVisitor, isModifierLike) : undefined; const classDeclaration = factory.createClassDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, modifiers, name, /*typeParameters*/ undefined, @@ -837,7 +838,7 @@ namespace ts { // } const heritageClauses = visitNodes(node.heritageClauses, visitor, isHeritageClause); const members = transformClassMembers(node); - const classExpression = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); + const classExpression = factory.createClassExpression(/*decorators*/ RESERVED, /*modifiers*/ undefined, name, /*typeParameters*/ undefined, heritageClauses, members); setOriginalNode(classExpression, node); setTextRange(classExpression, location); @@ -866,7 +867,7 @@ namespace ts { } const classExpression = factory.createClassExpression( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, node.name, /*typeParameters*/ undefined, @@ -895,7 +896,7 @@ namespace ts { for (const parameter of parametersWithPropertyAssignments) { if (isIdentifier(parameter.name)) { members.push(setOriginalNode(factory.createPropertyDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, parameter.name, /*questionOrExclamationToken*/ undefined, @@ -976,12 +977,13 @@ namespace ts { const numParameters = firstParameterIsThis ? parameters.length - 1 : parameters.length; for (let i = 0; i < numParameters; i++) { const parameter = parameters[i + firstParameterOffset]; - if (decorators || parameter.decorators) { + const parameterDecorators = getDecorators(parameter); + if (decorators || parameterDecorators) { if (!decorators) { decorators = new Array(numParameters); } - decorators[i] = parameter.decorators; + decorators[i] = parameterDecorators; } } } @@ -996,7 +998,7 @@ namespace ts { * @param node The class node. */ function getAllDecoratorsOfConstructor(node: ClassExpression | ClassDeclaration): AllDecorators | undefined { - const decorators = node.decorators; + const decorators = getDecorators(node); const parameters = getDecoratorsOfParameters(getFirstConstructorWithBody(node)); if (!decorators && !parameters) { return undefined; @@ -1043,12 +1045,16 @@ namespace ts { } const { firstAccessor, secondAccessor, setAccessor } = getAllAccessorDeclarations(node.members, accessor); - const firstAccessorWithDecorators = firstAccessor.decorators ? firstAccessor : secondAccessor && secondAccessor.decorators ? secondAccessor : undefined; + const firstAccessorWithDecorators = + hasDecorators(firstAccessor) ? firstAccessor : + secondAccessor && hasDecorators(secondAccessor) ? secondAccessor : + undefined; + if (!firstAccessorWithDecorators || accessor !== firstAccessorWithDecorators) { return undefined; } - const decorators = firstAccessorWithDecorators.decorators; + const decorators = getDecorators(firstAccessorWithDecorators); const parameters = getDecoratorsOfParameters(setAccessor); if (!decorators && !parameters) { return undefined; @@ -1067,7 +1073,7 @@ namespace ts { return undefined; } - const decorators = method.decorators; + const decorators = getDecorators(method); const parameters = getDecoratorsOfParameters(method); if (!decorators && !parameters) { return undefined; @@ -1082,7 +1088,7 @@ namespace ts { * @param property The class property member. */ function getAllDecoratorsOfProperty(property: PropertyDeclaration): AllDecorators | undefined { - const decorators = property.decorators; + const decorators = getDecorators(property); if (!decorators) { return undefined; @@ -1836,7 +1842,7 @@ namespace ts { // The names are used more than once when: // - the property is non-static and its initializer is moved to the constructor (when there are parameter property assignments). // - the property has a decorator. - if (isComputedPropertyName(name) && ((!hasStaticModifier(member) && currentClassHasParameterProperties) || some(member.decorators))) { + if (isComputedPropertyName(name) && ((!hasStaticModifier(member) && currentClassHasParameterProperties) || hasDecorators(member))) { const expression = visitNode(name.expression, visitor, isExpression); const innerExpression = skipPartiallyEmittedExpressions(expression); if (!isSimpleInlineableExpression(innerExpression)) { @@ -1897,8 +1903,8 @@ namespace ts { } const updated = factory.updatePropertyDeclaration( node, - /*decorators*/ undefined, - visitNodes(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + visitNodes(node.modifiers, modifierVisitor, isModifierLike), visitPropertyNameOfClassElement(node), /*questionOrExclamationToken*/ undefined, /*type*/ undefined, @@ -1920,7 +1926,7 @@ namespace ts { return factory.updateConstructorDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, visitParameterList(node.parameters, visitor, context), transformConstructorBody(node.body, node) @@ -2036,8 +2042,8 @@ namespace ts { } const updated = factory.updateMethodDeclaration( node, - /*decorators*/ undefined, - visitNodes(node.modifiers, modifierVisitor, isModifier), + /*decorators*/ RESERVED, + visitNodes(node.modifiers, modifierVisitor, isModifierLike), node.asteriskToken, visitPropertyNameOfClassElement(node), /*questionToken*/ undefined, @@ -2071,8 +2077,8 @@ namespace ts { } const updated = factory.updateGetAccessorDeclaration( node, - /*decorators*/ undefined, - visitNodes(node.modifiers, modifierVisitor, isModifier), + /*decorators*/ RESERVED, + visitNodes(node.modifiers, modifierVisitor, isModifierLike), visitPropertyNameOfClassElement(node), visitParameterList(node.parameters, visitor, context), /*type*/ undefined, @@ -2093,8 +2099,8 @@ namespace ts { } const updated = factory.updateSetAccessorDeclaration( node, - /*decorators*/ undefined, - visitNodes(node.modifiers, modifierVisitor, isModifier), + /*decorators*/ RESERVED, + visitNodes(node.modifiers, modifierVisitor, isModifierLike), visitPropertyNameOfClassElement(node), visitParameterList(node.parameters, visitor, context), visitFunctionBody(node.body, visitor, context) || factory.createBlock([]) @@ -2114,7 +2120,7 @@ namespace ts { } const updated = factory.updateFunctionDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, visitNodes(node.modifiers, modifierVisitor, isModifier), node.asteriskToken, node.name, @@ -2168,7 +2174,7 @@ namespace ts { const updated = factory.updateParameterDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, node.dotDotDotToken, visitNode(node.name, visitor, isBindingName), @@ -2405,7 +2411,7 @@ namespace ts { /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, - [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], + [factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformEnumBody(node, containerName) ), @@ -2706,7 +2712,7 @@ namespace ts { /*asteriskToken*/ undefined, /*name*/ undefined, /*typeParameters*/ undefined, - [factory.createParameterDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], + [factory.createParameterDeclaration(/*decorators*/ RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, parameterName)], /*type*/ undefined, transformModuleBody(node, containerName) ), @@ -2841,7 +2847,7 @@ namespace ts { compilerOptions.importsNotUsedAsValues === ImportsNotUsedAsValues.Error ? factory.updateImportDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, importClause, node.moduleSpecifier, @@ -2933,7 +2939,7 @@ namespace ts { return exportClause ? factory.updateExportDeclaration( node, - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, node.isTypeOnly, exportClause, @@ -3004,7 +3010,7 @@ namespace ts { return setOriginalNode( setTextRange( factory.createImportDeclaration( - /*decorators*/ undefined, + /*decorators*/ RESERVED, /*modifiers*/ undefined, /*importClause*/ undefined, node.moduleReference.expression, diff --git a/src/compiler/types.ts b/src/compiler/types.ts index 1a221cc3932d2..55c707db96405 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -824,6 +824,7 @@ namespace ts { Override = 1 << 14, // Override method. In = 1 << 15, // Contravariance modifier Out = 1 << 16, // Covariance modifier + Decorator = 1 << 17, // Contains a decorator. HasComputedFlags = 1 << 29, // Modifier flags have been computed AccessibilityModifier = Public | Private | Protected, @@ -833,7 +834,8 @@ namespace ts { TypeScriptModifier = Ambient | Public | Private | Protected | Readonly | Abstract | Const | Override | In | Out, ExportDefault = Export | Default, - All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Async | Default | Const | Deprecated | Override | In | Out + All = Export | Ambient | Public | Private | Protected | Static | Readonly | Abstract | Async | Default | Const | Deprecated | Override | In | Out | Decorator, + Modifier = All & ~Decorator } export const enum JsxFlags { @@ -865,8 +867,6 @@ namespace ts { readonly flags: NodeFlags; /* @internal */ modifierFlagsCache: ModifierFlags; /* @internal */ readonly transformFlags: TransformFlags; // Flags for transforms - readonly decorators?: NodeArray; // Array of decorators (in document order) - readonly modifiers?: ModifiersArray; // Array of modifiers /* @internal */ id?: NodeId; // Unique id (used to look up NodeLinks) readonly parent: Node; // Parent node (initialized by binding) /* @internal */ original?: Node; // The original node if this is an updated node. @@ -963,6 +963,23 @@ namespace ts { | JSDocVariadicType ; + // NOTE: Changing the following list requires changes to: + // - `canHaveIllegalType` in factory/utilities.ts + /* @internal */ + export type HasIllegalType = + | ConstructorDeclaration + | SetAccessorDeclaration + ; + + // NOTE: Changing the following list requires changes to: + // - `canHaveIllegalTypeParameters` in factory/utilities.ts + /* @internal */ + export type HasIllegalTypeParameters = + | ConstructorDeclaration + | SetAccessorDeclaration + | GetAccessorDeclaration + ; + export type HasTypeArguments = | CallExpression | NewExpression @@ -982,16 +999,59 @@ namespace ts { | VariableDeclaration | ParameterDeclaration | BindingElement - | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember ; - // NOTE: Changing this list requires changes to `canHaveModifiers` in factory/utilities.ts and `updateModifiers` in factory/nodeFactory.ts /* @internal */ + export type HasIllegalExpressionInitializer = + | PropertySignature + ; + + // NOTE: Changing the following list requires changes to: + // - `canHaveDecorators` in factory/utilities.ts + // - `updateModifiers` in factory/nodeFactory.ts + export type HasDecorators = + | ParameterDeclaration + | PropertyDeclaration + | MethodDeclaration + | GetAccessorDeclaration + | SetAccessorDeclaration + | ClassExpression + | ClassDeclaration + ; + + // NOTE: Changing the following list requires changes to: + // - `canHaveIllegalDecorators` in factory/utilities.ts + /* @internal */ + export type HasIllegalDecorators = + | PropertyAssignment + | ShorthandPropertyAssignment + | FunctionDeclaration + | ConstructorDeclaration + | IndexSignatureDeclaration + | ClassStaticBlockDeclaration + | MissingDeclaration + | VariableStatement + | InterfaceDeclaration + | TypeAliasDeclaration + | EnumDeclaration + | ModuleDeclaration + | ImportEqualsDeclaration + | ImportDeclaration + | NamespaceExportDeclaration + | ExportDeclaration + | ExportAssignment + ; + + // NOTE: Changing the following list requires changes to: + // - `canHaveModifiers` in factory/utilities.ts + // - `updateModifiers` in factory/nodeFactory.ts export type HasModifiers = + | TypeParameterDeclaration | ParameterDeclaration + | ConstructorTypeNode | PropertySignature | PropertyDeclaration | MethodSignature @@ -1016,6 +1076,18 @@ namespace ts { | ExportDeclaration ; + // NOTE: Changing the following list requires changes to: + // - `canHaveIllegalModifiers` in factory/utilities.ts + /* @internal */ + export type HasIllegalModifiers = + | ClassStaticBlockDeclaration + | PropertyAssignment + | ShorthandPropertyAssignment + | MissingDeclaration + | FunctionTypeNode + | NamespaceExportDeclaration + ; + /* @internal */ export interface MutableNodeArray extends Array, TextRange { hasTrailingComma: boolean; @@ -1102,6 +1174,8 @@ namespace ts { | StaticKeyword ; + export type ModifierLike = Modifier | Decorator; + export type AccessibilityModifier = | PublicKeyword | PrivateKeyword @@ -1254,6 +1328,7 @@ namespace ts { export interface TypeParameterDeclaration extends NamedDeclaration { readonly kind: SyntaxKind.TypeParameter; readonly parent: DeclarationWithTypeParameterChildren | InferTypeNode; + readonly modifiers?: NodeArray; readonly name: Identifier; /** Note: Consider calling `getEffectiveConstraintOfTypeParameter` */ readonly constraint?: TypeNode; @@ -1266,9 +1341,9 @@ namespace ts { export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { readonly kind: SignatureDeclaration["kind"]; readonly name?: PropertyName; - readonly typeParameters?: NodeArray; + readonly typeParameters?: NodeArray | undefined; readonly parameters: NodeArray; - readonly type?: TypeNode; + readonly type?: TypeNode | undefined; /* @internal */ typeArguments?: NodeArray; // Used for quick info, replaces typeParameters for instantiated signatures } @@ -1318,6 +1393,7 @@ namespace ts { export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { readonly kind: SyntaxKind.Parameter; readonly parent: SignatureDeclaration; + readonly modifiers?: NodeArray; readonly dotDotDotToken?: DotDotDotToken; // Present on rest parameter readonly name: BindingName; // Declared parameter name. readonly questionToken?: QuestionToken; // Present on optional parameter @@ -1339,15 +1415,19 @@ namespace ts { export interface PropertySignature extends TypeElement, JSDocContainer { readonly kind: SyntaxKind.PropertySignature; + readonly modifiers?: NodeArray; readonly name: PropertyName; // Declared property name readonly questionToken?: QuestionToken; // Present on optional property readonly type?: TypeNode; // Optional type annotation - initializer?: Expression; // Present for use with reporting a grammar error + + // The following properties are used only to report grammar errors + /* @internal */ illegalInitializer?: Expression; // Present for use with reporting a grammar error } export interface PropertyDeclaration extends ClassElement, JSDocContainer { readonly kind: SyntaxKind.PropertyDeclaration; readonly parent: ClassLikeDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; readonly questionToken?: QuestionToken; // Present for use with reporting a grammar error readonly exclamationToken?: ExclamationToken; @@ -1401,21 +1481,29 @@ namespace ts { readonly kind: SyntaxKind.PropertyAssignment; readonly parent: ObjectLiteralExpression; readonly name: PropertyName; - readonly questionToken?: QuestionToken; // Present for use with reporting a grammar error - readonly exclamationToken?: ExclamationToken; // Present for use with reporting a grammar error readonly initializer: Expression; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; + /* @internal */ illegalModifiers?: NodeArray; + /* @internal */ illegalQuestionToken?: QuestionToken; + /* @internal */ illegalExclamationToken?: ExclamationToken; } export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.ShorthandPropertyAssignment; readonly parent: ObjectLiteralExpression; readonly name: Identifier; - readonly questionToken?: QuestionToken; - readonly exclamationToken?: ExclamationToken; // used when ObjectLiteralExpression is used in ObjectAssignmentPattern // it is a grammar error to appear in actual object initializer: readonly equalsToken?: EqualsToken; readonly objectAssignmentInitializer?: Expression; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; + /* @internal */ illegalModifiers?: NodeArray; + /* @internal */ illegalQuestionToken?: QuestionToken; + /* @internal */ illegalExclamationToken?: ExclamationToken; } export interface SpreadAssignment extends ObjectLiteralElement, JSDocContainer { @@ -1468,10 +1556,10 @@ namespace ts { export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; - readonly asteriskToken?: AsteriskToken; - readonly questionToken?: QuestionToken; - readonly exclamationToken?: ExclamationToken; - readonly body?: Block | Expression; + readonly asteriskToken?: AsteriskToken | undefined; + readonly questionToken?: QuestionToken | undefined; + readonly exclamationToken?: ExclamationToken | undefined; + readonly body?: Block | Expression | undefined; /* @internal */ endFlowNode?: FlowNode; /* @internal */ returnFlowNode?: FlowNode; } @@ -1489,13 +1577,18 @@ namespace ts { export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { readonly kind: SyntaxKind.FunctionDeclaration; + readonly modifiers?: NodeArray; readonly name?: Identifier; readonly body?: FunctionBody; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; } export interface MethodSignature extends SignatureDeclarationBase, TypeElement { readonly kind: SyntaxKind.MethodSignature; readonly parent: ObjectTypeDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; } @@ -1511,17 +1604,27 @@ namespace ts { export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.MethodDeclaration; readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly modifiers?: NodeArray | undefined; readonly name: PropertyName; - readonly body?: FunctionBody; - /* @internal*/ exclamationToken?: ExclamationToken; // Present for use with reporting a grammar error + readonly exclamationToken?: undefined; // A method cannot have an exclamation token + readonly body?: FunctionBody | undefined; + + // The following properties are used only to report grammar errors + /* @internal*/ illegalExclamationToken?: ExclamationToken; } export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { readonly kind: SyntaxKind.Constructor; readonly parent: ClassLikeDeclaration; - readonly body?: FunctionBody; - /* @internal */ typeParameters?: NodeArray; // Present for use with reporting a grammar error - /* @internal */ type?: TypeNode; // Present for use with reporting a grammar error + readonly modifiers?: NodeArray | undefined; + readonly body?: FunctionBody | undefined; + readonly typeParameters?: undefined; // A constructor cannot have type parameters + readonly type?: undefined; // A constructor cannot have a return type annotation + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; + /* @internal */ illegalTypeParameters?: NodeArray; + /* @internal */ illegalType?: TypeNode; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ @@ -1535,9 +1638,13 @@ namespace ts { export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.GetAccessor; readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; + readonly typeParameters?: undefined; // A get accessor cannot have type parameters readonly body?: FunctionBody; - /* @internal */ typeParameters?: NodeArray; // Present for use with reporting a grammar error + + // The following properties are used only to report grammar errors + /* @internal */ illegalTypeParameters?: NodeArray; } // See the comment on MethodDeclaration for the intuition behind SetAccessorDeclaration being a @@ -1545,10 +1652,15 @@ namespace ts { export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.SetAccessor; readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; + readonly typeParameters?: undefined; // A set accessor cannot have type parameters + readonly type?: undefined; // A set accessor cannot have a return type readonly body?: FunctionBody; - /* @internal */ typeParameters?: NodeArray; // Present for use with reporting a grammar error - /* @internal */ type?: TypeNode; // Present for use with reporting a grammar error + + // The following properties are used only to report grammar errors + /* @internal */ illegalTypeParameters?: NodeArray; + /* @internal */ illegalType?: TypeNode; } export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; @@ -1556,17 +1668,24 @@ namespace ts { export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { readonly kind: SyntaxKind.IndexSignature; readonly parent: ObjectTypeDeclaration; + readonly modifiers?: NodeArray; readonly type: TypeNode; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; } export interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer { readonly kind: SyntaxKind.ClassStaticBlockDeclaration; readonly parent: ClassDeclaration | ClassExpression; readonly body: Block; - /* @internal */ readonly decorators?: NodeArray; // Present for use with reporting a grammar error - /* @internal */ readonly modifier?: ModifiersArray; // Present for use with reporting a grammar error + /* @internal */ endFlowNode?: FlowNode; /* @internal */ returnFlowNode?: FlowNode; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; + /* @internal */ illegalModifiers?: NodeArray; } export interface TypeNode extends Node { @@ -1613,10 +1732,15 @@ namespace ts { export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { readonly kind: SyntaxKind.FunctionType; + readonly modifiers?: undefined; // Function types cannot have modifiers + + // The following properties are used only to report grammar errors + /* @internal */ illegalModifiers?: NodeArray; } export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { readonly kind: SyntaxKind.ConstructorType; + readonly modifiers?: NodeArray; } export interface NodeWithTypeArguments extends TypeNode { @@ -2137,12 +2261,14 @@ namespace ts { export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { readonly kind: SyntaxKind.FunctionExpression; + readonly modifiers?: NodeArray; readonly name?: Identifier; readonly body: FunctionBody; // Required, whereas the member inherited from FunctionDeclaration is optional } export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { readonly kind: SyntaxKind.ArrowFunction; + readonly modifiers?: NodeArray; readonly equalsGreaterThanToken: EqualsGreaterThanToken; readonly body: ConciseBody; readonly name: never; @@ -2698,10 +2824,12 @@ namespace ts { } export interface MissingDeclaration extends DeclarationStatement { - /*@internal*/ decorators?: NodeArray; // Present for use with reporting a grammar error - /*@internal*/ modifiers?: ModifiersArray; // Present for use with reporting a grammar error readonly kind: SyntaxKind.MissingDeclaration; readonly name?: Identifier; + + // The following properties are used only to report grammar errors + /*@internal*/ illegalDecorators?: NodeArray; + /*@internal*/ illegalModifiers?: NodeArray; } export type BlockLike = @@ -2718,9 +2846,12 @@ namespace ts { } export interface VariableStatement extends Statement { - /* @internal*/ decorators?: NodeArray; // Present for use with reporting a grammar error readonly kind: SyntaxKind.VariableStatement; + readonly modifiers?: NodeArray; readonly declarationList: VariableDeclarationList; + + // The following properties are used only to report grammar errors + /* @internal*/ illegalDecorators?: NodeArray; } export interface ExpressionStatement extends Statement { @@ -2899,12 +3030,14 @@ namespace ts { export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { readonly kind: SyntaxKind.ClassDeclaration; + readonly modifiers?: NodeArray; /** May be undefined in `export default class { ... }`. */ readonly name?: Identifier; } export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { readonly kind: SyntaxKind.ClassExpression; + readonly modifiers?: NodeArray; } export type ClassLikeDeclaration = @@ -2920,15 +3053,19 @@ namespace ts { export interface TypeElement extends NamedDeclaration { _typeElementBrand: any; readonly name?: PropertyName; - readonly questionToken?: QuestionToken; + readonly questionToken?: QuestionToken | undefined; } export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.InterfaceDeclaration; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly typeParameters?: NodeArray; readonly heritageClauses?: NodeArray; readonly members: NodeArray; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; } export interface HeritageClause extends Node { @@ -2940,9 +3077,13 @@ namespace ts { export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.TypeAliasDeclaration; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly typeParameters?: NodeArray; readonly type: TypeNode; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; } export interface EnumMember extends NamedDeclaration, JSDocContainer { @@ -2956,8 +3097,12 @@ namespace ts { export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.EnumDeclaration; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly members: NodeArray; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; } export type ModuleName = @@ -2978,8 +3123,12 @@ namespace ts { export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ModuleDeclaration; readonly parent: ModuleBody | SourceFile; + readonly modifiers?: NodeArray; readonly name: ModuleName; readonly body?: ModuleBody | JSDocNamespaceDeclaration; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; } export type NamespaceBody = @@ -3021,12 +3170,16 @@ namespace ts { export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ImportEqualsDeclaration; readonly parent: SourceFile | ModuleBlock; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly isTypeOnly: boolean; // 'EntityName' for an internal module reference, 'ExternalModuleReference' for an external // module reference. readonly moduleReference: ModuleReference; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; } export interface ExternalModuleReference extends Node { @@ -3042,10 +3195,14 @@ namespace ts { export interface ImportDeclaration extends Statement { readonly kind: SyntaxKind.ImportDeclaration; readonly parent: SourceFile | ModuleBlock; + readonly modifiers?: NodeArray; readonly importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ readonly moduleSpecifier: Expression; readonly assertClause?: AssertClause; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; } export type NamedImportBindings = @@ -3103,19 +3260,25 @@ namespace ts { export interface NamespaceExportDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.NamespaceExportDeclaration; readonly name: Identifier; - /* @internal */ decorators?: NodeArray; // Present for use with reporting a grammar error - /* @internal */ modifiers?: ModifiersArray; // Present for use with reporting a grammar error + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; + /* @internal */ illegalModifiers?: NodeArray; } export interface ExportDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ExportDeclaration; readonly parent: SourceFile | ModuleBlock; + readonly modifiers?: NodeArray; readonly isTypeOnly: boolean; /** Will not be assigned in the case of `export * from "foo";` */ readonly exportClause?: NamedExportBindings; /** If this is not a StringLiteral it will be a grammar error. */ readonly moduleSpecifier?: Expression; readonly assertClause?: AssertClause; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; } export interface NamedImports extends Node { @@ -3175,8 +3338,12 @@ namespace ts { export interface ExportAssignment extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ExportAssignment; readonly parent: SourceFile; + readonly modifiers?: NodeArray; readonly isExportEquals?: boolean; readonly expression: Expression; + + // The following properties are used only to report grammar errors + /* @internal */ illegalDecorators?: NodeArray; } export interface FileReference extends TextRange { @@ -7278,13 +7445,9 @@ namespace ts { // createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; - /** @deprecated */ - createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - /** @deprecated */ - updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + createParameterDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + updateParameterDeclaration(node: ParameterDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; createDecorator(expression: Expression): Decorator; updateDecorator(node: Decorator, expression: Expression): Decorator; @@ -7294,29 +7457,29 @@ namespace ts { createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined): PropertySignature; updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined): PropertySignature; - createPropertyDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - updatePropertyDeclaration(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + createPropertyDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + updatePropertyDeclaration(node: PropertyDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; createMethodSignature(modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): MethodSignature; updateMethodSignature(node: MethodSignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): MethodSignature; - createMethodDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - updateMethodDeclaration(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - createConstructorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; - updateConstructorDeclaration(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; - createGetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - updateGetAccessorDeclaration(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - createSetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; - updateSetAccessorDeclaration(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + createMethodDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + updateMethodDeclaration(node: MethodDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + createConstructorDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + updateConstructorDeclaration(node: ConstructorDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + createGetAccessorDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + updateGetAccessorDeclaration(node: GetAccessorDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + createSetAccessorDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + updateSetAccessorDeclaration(node: SetAccessorDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; - /* @internal */ createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): IndexSignatureDeclaration; // eslint-disable-line @typescript-eslint/unified-signatures - updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + createIndexSignature(decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + /* @internal */ createIndexSignature(decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): IndexSignatureDeclaration; // eslint-disable-line @typescript-eslint/unified-signatures + updateIndexSignature(node: IndexSignatureDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; createTemplateLiteralTypeSpan(type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan; updateTemplateLiteralTypeSpan(node: TemplateLiteralTypeSpan, type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan; - createClassStaticBlockDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; - updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; + createClassStaticBlockDeclaration(decorators: null, modifiers: null, body: Block): ClassStaticBlockDeclaration; + updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: null, modifiers: null, body: Block): ClassStaticBlockDeclaration; // // Types @@ -7330,11 +7493,7 @@ namespace ts { createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): FunctionTypeNode; updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): FunctionTypeNode; createConstructorTypeNode(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; - /** @deprecated */ - createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; updateConstructorTypeNode(node: ConstructorTypeNode, modifiers: readonly Modifier[] | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): ConstructorTypeNode; - /** @deprecated */ - updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): ConstructorTypeNode; createTypeQueryNode(exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode; updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode; createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; @@ -7357,11 +7516,7 @@ namespace ts { updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - /*@deprecated*/ - createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; createImportTypeNode(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; - /*@deprecated*/ - updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode; updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, assertions: ImportTypeAssertionContainer | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode; createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; @@ -7454,8 +7609,8 @@ namespace ts { updateYieldExpression(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression | undefined): YieldExpression; createSpreadElement(expression: Expression): SpreadElement; updateSpreadElement(node: SpreadElement, expression: Expression): SpreadElement; - createClassExpression(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; - updateClassExpression(node: ClassExpression, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + createClassExpression(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + updateClassExpression(node: ClassExpression, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; createOmittedExpression(): OmittedExpression; createExpressionWithTypeArguments(expression: Expression, typeArguments: readonly TypeNode[] | undefined): ExpressionWithTypeArguments; updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, expression: Expression, typeArguments: readonly TypeNode[] | undefined): ExpressionWithTypeArguments; @@ -7520,28 +7675,28 @@ namespace ts { updateVariableDeclaration(node: VariableDeclaration, name: BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; - createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; - updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; - createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; - updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; - createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; - updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; - createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; - updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; - createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + createFunctionDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + updateFunctionDeclaration(node: FunctionDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + createClassDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + updateClassDeclaration(node: ClassDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + createInterfaceDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + createTypeAliasDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + createEnumDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + updateEnumDeclaration(node: EnumDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + createModuleDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + updateModuleDeclaration(node: ModuleDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; createModuleBlock(statements: readonly Statement[]): ModuleBlock; updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause): ImportDeclaration; - updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + createImportEqualsDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + createImportDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause): ImportDeclaration; + updateImportDeclaration(node: ImportDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; createAssertClause(elements: NodeArray, multiLine?: boolean): AssertClause; @@ -7558,10 +7713,10 @@ namespace ts { updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; createImportSpecifier(isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; - createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; - updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; + createExportAssignment(decorators: null, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + updateExportAssignment(node: ExportAssignment, decorators: null, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + createExportDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; + updateExportDeclaration(node: ExportDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; createExportSpecifier(isTypeOnly: boolean, propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; @@ -8580,13 +8735,12 @@ namespace ts { PreferNewLine = 1 << 16, // Prefer adding a LineTerminator between synthesized nodes. NoTrailingNewLine = 1 << 17, // Do not emit a trailing NewLine for a MultiLine list. NoInterveningComments = 1 << 18, // Do not emit comments between each node - NoSpaceIfEmpty = 1 << 19, // If the literal is empty, do not add spaces between braces. SingleElement = 1 << 20, SpaceAfterList = 1 << 21, // Add space after list // Precomputed Formats - Modifiers = SingleLine | SpaceBetweenSiblings | NoInterveningComments, + Modifiers = SingleLine | SpaceBetweenSiblings | NoInterveningComments | SpaceAfterList, HeritageClauses = SingleLine | SpaceBetweenSiblings, SingleLineTypeLiteralMembers = SingleLine | SpaceBetweenBraces | SpaceBetweenSiblings, MultiLineTypeLiteralMembers = MultiLine | Indented | OptionalIfEmpty, diff --git a/src/compiler/utilities.ts b/src/compiler/utilities.ts index 7d860fa7a61e6..fd484d3480820 100644 --- a/src/compiler/utilities.ts +++ b/src/compiler/utilities.ts @@ -502,11 +502,12 @@ namespace ts { } export function getNonDecoratorTokenPosOfNode(node: Node, sourceFile?: SourceFileLike): number { - if (nodeIsMissing(node) || !node.decorators) { + const lastDecorator = !nodeIsMissing(node) && canHaveModifiers(node) ? findLast(node.modifiers, isDecorator) : undefined; + if (!lastDecorator) { return getTokenPosOfNode(node, sourceFile); } - return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, node.decorators.end); + return skipTrivia((sourceFile || getSourceFileOfNode(node)).text, lastDecorator.end); } export function getSourceTextOfNodeFromSourceFile(sourceFile: SourceFile, node: Node, includeTrivia = false): string { @@ -1936,7 +1937,7 @@ namespace ts { export function nodeIsDecorated(node: ClassElement, parent: Node): boolean; export function nodeIsDecorated(node: Node, parent: Node, grandparent: Node): boolean; export function nodeIsDecorated(node: Node, parent?: Node, grandparent?: Node): boolean { - return node.decorators !== undefined + return hasDecorators(node) && nodeCanBeDecorated(node, parent!, grandparent!); // TODO: GH#18217 } @@ -4912,6 +4913,10 @@ namespace ts { return hasEffectiveModifier(node, ModifierFlags.Readonly); } + export function hasDecorators(node: Node): boolean { + return hasSyntacticModifier(node, ModifierFlags.Decorator); + } + export function getSelectedEffectiveModifierFlags(node: Node, flags: ModifierFlags): ModifierFlags { return getEffectiveModifierFlags(node) & flags; } @@ -4989,14 +4994,14 @@ namespace ts { * NOTE: This function does not use `parent` pointers and will not include modifiers from JSDoc. */ export function getSyntacticModifierFlagsNoCache(node: Node): ModifierFlags { - let flags = modifiersToFlags(node.modifiers); + let flags = canHaveModifiers(node) ? modifiersToFlags(node.modifiers) : ModifierFlags.None; if (node.flags & NodeFlags.NestedNamespace || (node.kind === SyntaxKind.Identifier && (node as Identifier).isInJSDocNamespace)) { flags |= ModifierFlags.Export; } return flags; } - export function modifiersToFlags(modifiers: readonly Modifier[] | undefined) { + export function modifiersToFlags(modifiers: readonly ModifierLike[] | undefined) { let flags = ModifierFlags.None; if (modifiers) { for (const modifier of modifiers) { @@ -5022,6 +5027,7 @@ namespace ts { case SyntaxKind.OverrideKeyword: return ModifierFlags.Override; case SyntaxKind.InKeyword: return ModifierFlags.In; case SyntaxKind.OutKeyword: return ModifierFlags.Out; + case SyntaxKind.Decorator: return ModifierFlags.Decorator; } return ModifierFlags.None; } @@ -5414,8 +5420,9 @@ namespace ts { * Moves the start position of a range past any decorators. */ export function moveRangePastDecorators(node: Node): TextRange { - return node.decorators && node.decorators.length > 0 - ? moveRangePos(node, node.decorators.end) + const lastDecorator = canHaveModifiers(node) ? findLast(node.modifiers, isDecorator) : undefined; + return lastDecorator + ? moveRangePos(node, lastDecorator.end) : node; } @@ -5423,7 +5430,7 @@ namespace ts { * Moves the start position of a range past any decorators or modifiers. */ export function moveRangePastModifiers(node: Node): TextRange { - return node.modifiers && node.modifiers.length > 0 + return canHaveModifiers(node) && node.modifiers && node.modifiers.length > 0 ? moveRangePos(node, node.modifiers.end) : moveRangePastDecorators(node); } @@ -7523,8 +7530,12 @@ namespace ts { return (node as TemplateLiteralTypeSpan).parent.templateSpans; case SyntaxKind.TemplateSpan: return (node as TemplateSpan).parent.templateSpans; - case SyntaxKind.Decorator: - return (node as Decorator).parent.decorators; + case SyntaxKind.Decorator: { + const { parent } = node as Decorator; + return canHaveDecorators(parent) ? parent.modifiers : + canHaveIllegalDecorators(parent) ? parent.illegalDecorators : + undefined; + } case SyntaxKind.HeritageClause: return (node as HeritageClause).parent.heritageClauses; } diff --git a/src/compiler/utilitiesPublic.ts b/src/compiler/utilitiesPublic.ts index ecfb4e52dafca..8edfa15f7a57b 100644 --- a/src/compiler/utilitiesPublic.ts +++ b/src/compiler/utilitiesPublic.ts @@ -645,6 +645,18 @@ namespace ts { } } + export function getDecorators(node: HasDecorators): readonly Decorator[] | undefined { + if (hasDecorators(node)) { + return filter(node.modifiers, isDecorator); + } + } + + export function getModifiers(node: HasModifiers): readonly Modifier[] | undefined { + if (hasSyntacticModifier(node, ModifierFlags.Modifier)) { + return filter(node.modifiers, isModifier); + } + } + function getJSDocParameterTagsWorker(param: ParameterDeclaration, noCache?: boolean): readonly JSDocParameterTag[] { if (param.name) { if (isIdentifier(param.name)) { @@ -932,6 +944,9 @@ namespace ts { if (node.typeParameters) { return node.typeParameters; } + if (canHaveIllegalTypeParameters(node) && node.illegalTypeParameters) { + return node.illegalTypeParameters; + } if (isInJSFile(node)) { const decls = getJSDocTypeParameterDeclarations(node); if (decls.length) { @@ -1329,6 +1344,10 @@ namespace ts { // Type members + export function isModifierLike(node: Node): node is ModifierLike { + return isModifier(node) || isDecorator(node); + } + export function isTypeElement(node: Node): node is TypeElement { const kind = node.kind; return kind === SyntaxKind.ConstructSignature @@ -1965,7 +1984,6 @@ namespace ts { case SyntaxKind.VariableDeclaration: case SyntaxKind.Parameter: case SyntaxKind.BindingElement: - case SyntaxKind.PropertySignature: case SyntaxKind.PropertyDeclaration: case SyntaxKind.PropertyAssignment: case SyntaxKind.EnumMember: diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index ef05168148e5a..43d7988263555 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -232,7 +232,7 @@ namespace ts { ) ); return factory.updateParameterDeclaration(parameter, - parameter.decorators, + /*decorators*/ RESERVED, parameter.modifiers, parameter.dotDotDotToken, factory.getGeneratedNameForNode(parameter), @@ -269,7 +269,7 @@ namespace ts { ) ); return factory.updateParameterDeclaration(parameter, - parameter.decorators, + /*decorators*/ RESERVED, parameter.modifiers, parameter.dotDotDotToken, parameter.name, @@ -393,8 +393,8 @@ namespace ts { case SyntaxKind.Parameter: Debug.type(node); return factory.updateParameterDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), - nodesVisitor(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + nodesVisitor(node.modifiers, visitor, isModifierLike), nodeVisitor(node.dotDotDotToken, tokenVisitor, isDotDotDotToken), nodeVisitor(node.name, visitor, isBindingName), nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), @@ -418,8 +418,8 @@ namespace ts { case SyntaxKind.PropertyDeclaration: Debug.type(node); return factory.updatePropertyDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), - nodesVisitor(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + nodesVisitor(node.modifiers, visitor, isModifierLike), nodeVisitor(node.name, visitor, isPropertyName), // QuestionToken and ExclamationToken is uniqued in Property Declaration and the signature of 'updateProperty' is that too nodeVisitor(node.questionToken || node.exclamationToken, tokenVisitor, isQuestionOrExclamationToken), @@ -439,8 +439,8 @@ namespace ts { case SyntaxKind.MethodDeclaration: Debug.type(node); return factory.updateMethodDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), - nodesVisitor(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + nodesVisitor(node.modifiers, visitor, isModifierLike), nodeVisitor(node.asteriskToken, tokenVisitor, isAsteriskToken), nodeVisitor(node.name, visitor, isPropertyName), nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), @@ -452,7 +452,7 @@ namespace ts { case SyntaxKind.Constructor: Debug.type(node); return factory.updateConstructorDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body!, visitor, context, nodeVisitor)); @@ -460,8 +460,8 @@ namespace ts { case SyntaxKind.GetAccessor: Debug.type(node); return factory.updateGetAccessorDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), - nodesVisitor(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + nodesVisitor(node.modifiers, visitor, isModifierLike), nodeVisitor(node.name, visitor, isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), nodeVisitor(node.type, visitor, isTypeNode), @@ -470,8 +470,8 @@ namespace ts { case SyntaxKind.SetAccessor: Debug.type(node); return factory.updateSetAccessorDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), - nodesVisitor(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + nodesVisitor(node.modifiers, visitor, isModifierLike), nodeVisitor(node.name, visitor, isPropertyName), visitParameterList(node.parameters, visitor, context, nodesVisitor), visitFunctionBody(node.body!, visitor, context, nodeVisitor)); @@ -481,8 +481,8 @@ namespace ts { context.startLexicalEnvironment(); context.suspendLexicalEnvironment(); return factory.updateClassStaticBlockDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), - nodesVisitor(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + /*modifiers*/ RESERVED, visitFunctionBody(node.body, visitor, context, nodeVisitor)); case SyntaxKind.CallSignature: @@ -502,7 +502,7 @@ namespace ts { case SyntaxKind.IndexSignature: Debug.type(node); return factory.updateIndexSignature(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), nodesVisitor(node.parameters, visitor, isParameterDeclaration), nodeVisitor(node.type, visitor, isTypeNode)); @@ -842,8 +842,8 @@ namespace ts { case SyntaxKind.ClassExpression: Debug.type(node); return factory.updateClassExpression(node, - nodesVisitor(node.decorators, visitor, isDecorator), - nodesVisitor(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + nodesVisitor(node.modifiers, visitor, isModifierLike), nodeVisitor(node.name, visitor, isIdentifier), nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, isHeritageClause), @@ -1003,7 +1003,7 @@ namespace ts { case SyntaxKind.FunctionDeclaration: Debug.type(node); return factory.updateFunctionDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), nodeVisitor(node.asteriskToken, tokenVisitor, isAsteriskToken), nodeVisitor(node.name, visitor, isIdentifier), @@ -1015,8 +1015,8 @@ namespace ts { case SyntaxKind.ClassDeclaration: Debug.type(node); return factory.updateClassDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), - nodesVisitor(node.modifiers, visitor, isModifier), + /*decorators*/ RESERVED, + nodesVisitor(node.modifiers, visitor, isModifierLike), nodeVisitor(node.name, visitor, isIdentifier), nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), nodesVisitor(node.heritageClauses, visitor, isHeritageClause), @@ -1025,7 +1025,7 @@ namespace ts { case SyntaxKind.InterfaceDeclaration: Debug.type(node); return factory.updateInterfaceDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), nodeVisitor(node.name, visitor, isIdentifier), nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), @@ -1035,7 +1035,7 @@ namespace ts { case SyntaxKind.TypeAliasDeclaration: Debug.type(node); return factory.updateTypeAliasDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), nodeVisitor(node.name, visitor, isIdentifier), nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), @@ -1044,7 +1044,7 @@ namespace ts { case SyntaxKind.EnumDeclaration: Debug.type(node); return factory.updateEnumDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), nodeVisitor(node.name, visitor, isIdentifier), nodesVisitor(node.members, visitor, isEnumMember)); @@ -1052,7 +1052,7 @@ namespace ts { case SyntaxKind.ModuleDeclaration: Debug.type(node); return factory.updateModuleDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), nodeVisitor(node.name, visitor, isModuleName), nodeVisitor(node.body, visitor, isModuleBody)); @@ -1075,7 +1075,7 @@ namespace ts { case SyntaxKind.ImportEqualsDeclaration: Debug.type(node); return factory.updateImportEqualsDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), node.isTypeOnly, nodeVisitor(node.name, visitor, isIdentifier), @@ -1084,7 +1084,7 @@ namespace ts { case SyntaxKind.ImportDeclaration: Debug.type(node); return factory.updateImportDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), nodeVisitor(node.importClause, visitor, isImportClause), nodeVisitor(node.moduleSpecifier, visitor, isExpression), @@ -1134,14 +1134,14 @@ namespace ts { case SyntaxKind.ExportAssignment: Debug.type(node); return factory.updateExportAssignment(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), nodeVisitor(node.expression, visitor, isExpression)); case SyntaxKind.ExportDeclaration: Debug.type(node); return factory.updateExportDeclaration(node, - nodesVisitor(node.decorators, visitor, isDecorator), + /*decorators*/ RESERVED, nodesVisitor(node.modifiers, visitor, isModifier), node.isTypeOnly, nodeVisitor(node.exportClause, visitor, isNamedExportBindings), diff --git a/src/deprecatedCompat/4.0/nodeFactoryTopLevelExports.ts b/src/deprecatedCompat/4.0/nodeFactoryTopLevelExports.ts new file mode 100644 index 0000000000000..f57a693d98eb2 --- /dev/null +++ b/src/deprecatedCompat/4.0/nodeFactoryTopLevelExports.ts @@ -0,0 +1,1306 @@ +// DEPRECATION: Node factory top-level exports +// DEPRECATION PLAN: +// - soft: 4.0 +// - warn: 4.1 +// - error: 5.0 +namespace ts { + + // NOTE: These exports are deprecated in favor of using a `NodeFactory` instance and exist here purely for backwards compatibility reasons. + const factoryDeprecation: DeprecationOptions = { since: "4.0", warnAfter: "4.1", message: "Use the appropriate method on 'ts.factory' or the 'factory' supplied by your transformation context instead." }; + + /** @deprecated Use `factory.createNodeArray` or the factory supplied by your transformation context instead. */ + export const createNodeArray = Debug.deprecate(factory.createNodeArray, factoryDeprecation); + + /** @deprecated Use `factory.createNumericLiteral` or the factory supplied by your transformation context instead. */ + export const createNumericLiteral = Debug.deprecate(factory.createNumericLiteral, factoryDeprecation); + + /** @deprecated Use `factory.createBigIntLiteral` or the factory supplied by your transformation context instead. */ + export const createBigIntLiteral = Debug.deprecate(factory.createBigIntLiteral, factoryDeprecation); + + /** @deprecated Use `factory.createStringLiteral` or the factory supplied by your transformation context instead. */ + export const createStringLiteral = Debug.deprecate(factory.createStringLiteral, factoryDeprecation); + + /** @deprecated Use `factory.createStringLiteralFromNode` or the factory supplied by your transformation context instead. */ + export const createStringLiteralFromNode = Debug.deprecate(factory.createStringLiteralFromNode, factoryDeprecation); + + /** @deprecated Use `factory.createRegularExpressionLiteral` or the factory supplied by your transformation context instead. */ + export const createRegularExpressionLiteral = Debug.deprecate(factory.createRegularExpressionLiteral, factoryDeprecation); + + /** @deprecated Use `factory.createLoopVariable` or the factory supplied by your transformation context instead. */ + export const createLoopVariable = Debug.deprecate(factory.createLoopVariable, factoryDeprecation); + + /** @deprecated Use `factory.createUniqueName` or the factory supplied by your transformation context instead. */ + export const createUniqueName = Debug.deprecate(factory.createUniqueName, factoryDeprecation); + + /** @deprecated Use `factory.createPrivateIdentifier` or the factory supplied by your transformation context instead. */ + export const createPrivateIdentifier = Debug.deprecate(factory.createPrivateIdentifier, factoryDeprecation); + + /** @deprecated Use `factory.createSuper` or the factory supplied by your transformation context instead. */ + export const createSuper = Debug.deprecate(factory.createSuper, factoryDeprecation); + + /** @deprecated Use `factory.createThis` or the factory supplied by your transformation context instead. */ + export const createThis = Debug.deprecate(factory.createThis, factoryDeprecation); + + /** @deprecated Use `factory.createNull` or the factory supplied by your transformation context instead. */ + export const createNull = Debug.deprecate(factory.createNull, factoryDeprecation); + + /** @deprecated Use `factory.createTrue` or the factory supplied by your transformation context instead. */ + export const createTrue = Debug.deprecate(factory.createTrue, factoryDeprecation); + + /** @deprecated Use `factory.createFalse` or the factory supplied by your transformation context instead. */ + export const createFalse = Debug.deprecate(factory.createFalse, factoryDeprecation); + + /** @deprecated Use `factory.createModifier` or the factory supplied by your transformation context instead. */ + export const createModifier = Debug.deprecate(factory.createModifier, factoryDeprecation); + + /** @deprecated Use `factory.createModifiersFromModifierFlags` or the factory supplied by your transformation context instead. */ + export const createModifiersFromModifierFlags = Debug.deprecate(factory.createModifiersFromModifierFlags, factoryDeprecation); + + /** @deprecated Use `factory.createQualifiedName` or the factory supplied by your transformation context instead. */ + export const createQualifiedName = Debug.deprecate(factory.createQualifiedName, factoryDeprecation); + + /** @deprecated Use `factory.updateQualifiedName` or the factory supplied by your transformation context instead. */ + export const updateQualifiedName = Debug.deprecate(factory.updateQualifiedName, factoryDeprecation); + + /** @deprecated Use `factory.createComputedPropertyName` or the factory supplied by your transformation context instead. */ + export const createComputedPropertyName = Debug.deprecate(factory.createComputedPropertyName, factoryDeprecation); + + /** @deprecated Use `factory.updateComputedPropertyName` or the factory supplied by your transformation context instead. */ + export const updateComputedPropertyName = Debug.deprecate(factory.updateComputedPropertyName, factoryDeprecation); + + /** @deprecated Use `factory.createTypeParameterDeclaration` or the factory supplied by your transformation context instead. */ + export const createTypeParameterDeclaration = Debug.deprecate(factory.createTypeParameterDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateTypeParameterDeclaration` or the factory supplied by your transformation context instead. */ + export const updateTypeParameterDeclaration = Debug.deprecate(factory.updateTypeParameterDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createParameterDeclaration` or the factory supplied by your transformation context instead. */ + export const createParameter = Debug.deprecate(factory.createParameterDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateParameterDeclaration` or the factory supplied by your transformation context instead. */ + export const updateParameter = Debug.deprecate(factory.updateParameterDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createDecorator` or the factory supplied by your transformation context instead. */ + export const createDecorator = Debug.deprecate(factory.createDecorator, factoryDeprecation); + + /** @deprecated Use `factory.updateDecorator` or the factory supplied by your transformation context instead. */ + export const updateDecorator = Debug.deprecate(factory.updateDecorator, factoryDeprecation); + + /** @deprecated Use `factory.createPropertyDeclaration` or the factory supplied by your transformation context instead. */ + export const createProperty = Debug.deprecate(factory.createPropertyDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updatePropertyDeclaration` or the factory supplied by your transformation context instead. */ + export const updateProperty = Debug.deprecate(factory.updatePropertyDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createMethodDeclaration` or the factory supplied by your transformation context instead. */ + export const createMethod = Debug.deprecate(factory.createMethodDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateMethodDeclaration` or the factory supplied by your transformation context instead. */ + export const updateMethod = Debug.deprecate(factory.updateMethodDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createConstructorDeclaration` or the factory supplied by your transformation context instead. */ + export const createConstructor = Debug.deprecate(factory.createConstructorDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateConstructorDeclaration` or the factory supplied by your transformation context instead. */ + export const updateConstructor = Debug.deprecate(factory.updateConstructorDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createGetAccessorDeclaration` or the factory supplied by your transformation context instead. */ + export const createGetAccessor = Debug.deprecate(factory.createGetAccessorDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateGetAccessorDeclaration` or the factory supplied by your transformation context instead. */ + export const updateGetAccessor = Debug.deprecate(factory.updateGetAccessorDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createSetAccessorDeclaration` or the factory supplied by your transformation context instead. */ + export const createSetAccessor = Debug.deprecate(factory.createSetAccessorDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateSetAccessorDeclaration` or the factory supplied by your transformation context instead. */ + export const updateSetAccessor = Debug.deprecate(factory.updateSetAccessorDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createCallSignature` or the factory supplied by your transformation context instead. */ + export const createCallSignature = Debug.deprecate(factory.createCallSignature, factoryDeprecation); + + /** @deprecated Use `factory.updateCallSignature` or the factory supplied by your transformation context instead. */ + export const updateCallSignature = Debug.deprecate(factory.updateCallSignature, factoryDeprecation); + + /** @deprecated Use `factory.createConstructSignature` or the factory supplied by your transformation context instead. */ + export const createConstructSignature = Debug.deprecate(factory.createConstructSignature, factoryDeprecation); + + /** @deprecated Use `factory.updateConstructSignature` or the factory supplied by your transformation context instead. */ + export const updateConstructSignature = Debug.deprecate(factory.updateConstructSignature, factoryDeprecation); + + /** @deprecated Use `factory.updateIndexSignature` or the factory supplied by your transformation context instead. */ + export const updateIndexSignature = Debug.deprecate(factory.updateIndexSignature, factoryDeprecation); + + /** @deprecated Use `factory.createKeywordTypeNode` or the factory supplied by your transformation context instead. */ + export const createKeywordTypeNode = Debug.deprecate(factory.createKeywordTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createTypePredicateNode` or the factory supplied by your transformation context instead. */ + export const createTypePredicateNodeWithModifier = Debug.deprecate(factory.createTypePredicateNode, factoryDeprecation); + + /** @deprecated Use `factory.updateTypePredicateNode` or the factory supplied by your transformation context instead. */ + export const updateTypePredicateNodeWithModifier = Debug.deprecate(factory.updateTypePredicateNode, factoryDeprecation); + + /** @deprecated Use `factory.createTypeReferenceNode` or the factory supplied by your transformation context instead. */ + export const createTypeReferenceNode = Debug.deprecate(factory.createTypeReferenceNode, factoryDeprecation); + + /** @deprecated Use `factory.updateTypeReferenceNode` or the factory supplied by your transformation context instead. */ + export const updateTypeReferenceNode = Debug.deprecate(factory.updateTypeReferenceNode, factoryDeprecation); + + /** @deprecated Use `factory.createFunctionTypeNode` or the factory supplied by your transformation context instead. */ + export const createFunctionTypeNode = Debug.deprecate(factory.createFunctionTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateFunctionTypeNode` or the factory supplied by your transformation context instead. */ + export const updateFunctionTypeNode = Debug.deprecate(factory.updateFunctionTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createConstructorTypeNode` or the factory supplied by your transformation context instead. */ + export const createConstructorTypeNode = Debug.deprecate(( + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: TypeNode + ) => { + return factory.createConstructorTypeNode(/*modifiers*/ undefined, typeParameters, parameters, type); + }, factoryDeprecation); + + /** @deprecated Use `factory.updateConstructorTypeNode` or the factory supplied by your transformation context instead. */ + export const updateConstructorTypeNode = Debug.deprecate(( + node: ConstructorTypeNode, + typeParameters: NodeArray | undefined, + parameters: NodeArray, + type: TypeNode + ) => { + return factory.updateConstructorTypeNode(node, node.modifiers, typeParameters, parameters, type); + }, factoryDeprecation); + + /** @deprecated Use `factory.createTypeQueryNode` or the factory supplied by your transformation context instead. */ + export const createTypeQueryNode = Debug.deprecate(factory.createTypeQueryNode, factoryDeprecation); + + /** @deprecated Use `factory.updateTypeQueryNode` or the factory supplied by your transformation context instead. */ + export const updateTypeQueryNode = Debug.deprecate(factory.updateTypeQueryNode, factoryDeprecation); + + /** @deprecated Use `factory.createTypeLiteralNode` or the factory supplied by your transformation context instead. */ + export const createTypeLiteralNode = Debug.deprecate(factory.createTypeLiteralNode, factoryDeprecation); + + /** @deprecated Use `factory.updateTypeLiteralNode` or the factory supplied by your transformation context instead. */ + export const updateTypeLiteralNode = Debug.deprecate(factory.updateTypeLiteralNode, factoryDeprecation); + + /** @deprecated Use `factory.createArrayTypeNode` or the factory supplied by your transformation context instead. */ + export const createArrayTypeNode = Debug.deprecate(factory.createArrayTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateArrayTypeNode` or the factory supplied by your transformation context instead. */ + export const updateArrayTypeNode = Debug.deprecate(factory.updateArrayTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createTupleTypeNode` or the factory supplied by your transformation context instead. */ + export const createTupleTypeNode = Debug.deprecate(factory.createTupleTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateTupleTypeNode` or the factory supplied by your transformation context instead. */ + export const updateTupleTypeNode = Debug.deprecate(factory.updateTupleTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createOptionalTypeNode` or the factory supplied by your transformation context instead. */ + export const createOptionalTypeNode = Debug.deprecate(factory.createOptionalTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateOptionalTypeNode` or the factory supplied by your transformation context instead. */ + export const updateOptionalTypeNode = Debug.deprecate(factory.updateOptionalTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createRestTypeNode` or the factory supplied by your transformation context instead. */ + export const createRestTypeNode = Debug.deprecate(factory.createRestTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateRestTypeNode` or the factory supplied by your transformation context instead. */ + export const updateRestTypeNode = Debug.deprecate(factory.updateRestTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createUnionTypeNode` or the factory supplied by your transformation context instead. */ + export const createUnionTypeNode = Debug.deprecate(factory.createUnionTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateUnionTypeNode` or the factory supplied by your transformation context instead. */ + export const updateUnionTypeNode = Debug.deprecate(factory.updateUnionTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createIntersectionTypeNode` or the factory supplied by your transformation context instead. */ + export const createIntersectionTypeNode = Debug.deprecate(factory.createIntersectionTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateIntersectionTypeNode` or the factory supplied by your transformation context instead. */ + export const updateIntersectionTypeNode = Debug.deprecate(factory.updateIntersectionTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createConditionalTypeNode` or the factory supplied by your transformation context instead. */ + export const createConditionalTypeNode = Debug.deprecate(factory.createConditionalTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateConditionalTypeNode` or the factory supplied by your transformation context instead. */ + export const updateConditionalTypeNode = Debug.deprecate(factory.updateConditionalTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createInferTypeNode` or the factory supplied by your transformation context instead. */ + export const createInferTypeNode = Debug.deprecate(factory.createInferTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateInferTypeNode` or the factory supplied by your transformation context instead. */ + export const updateInferTypeNode = Debug.deprecate(factory.updateInferTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createImportTypeNode` or the factory supplied by your transformation context instead. */ + export const createImportTypeNode = Debug.deprecate(factory.createImportTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateImportTypeNode` or the factory supplied by your transformation context instead. */ + export const updateImportTypeNode = Debug.deprecate(factory.updateImportTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createParenthesizedType` or the factory supplied by your transformation context instead. */ + export const createParenthesizedType = Debug.deprecate(factory.createParenthesizedType, factoryDeprecation); + + /** @deprecated Use `factory.updateParenthesizedType` or the factory supplied by your transformation context instead. */ + export const updateParenthesizedType = Debug.deprecate(factory.updateParenthesizedType, factoryDeprecation); + + /** @deprecated Use `factory.createThisTypeNode` or the factory supplied by your transformation context instead. */ + export const createThisTypeNode = Debug.deprecate(factory.createThisTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateTypeOperatorNode` or the factory supplied by your transformation context instead. */ + export const updateTypeOperatorNode = Debug.deprecate(factory.updateTypeOperatorNode, factoryDeprecation); + + /** @deprecated Use `factory.createIndexedAccessTypeNode` or the factory supplied by your transformation context instead. */ + export const createIndexedAccessTypeNode = Debug.deprecate(factory.createIndexedAccessTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateIndexedAccessTypeNode` or the factory supplied by your transformation context instead. */ + export const updateIndexedAccessTypeNode = Debug.deprecate(factory.updateIndexedAccessTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createMappedTypeNode` or the factory supplied by your transformation context instead. */ + export const createMappedTypeNode = Debug.deprecate(factory.createMappedTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateMappedTypeNode` or the factory supplied by your transformation context instead. */ + export const updateMappedTypeNode = Debug.deprecate(factory.updateMappedTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createLiteralTypeNode` or the factory supplied by your transformation context instead. */ + export const createLiteralTypeNode = Debug.deprecate(factory.createLiteralTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.updateLiteralTypeNode` or the factory supplied by your transformation context instead. */ + export const updateLiteralTypeNode = Debug.deprecate(factory.updateLiteralTypeNode, factoryDeprecation); + + /** @deprecated Use `factory.createObjectBindingPattern` or the factory supplied by your transformation context instead. */ + export const createObjectBindingPattern = Debug.deprecate(factory.createObjectBindingPattern, factoryDeprecation); + + /** @deprecated Use `factory.updateObjectBindingPattern` or the factory supplied by your transformation context instead. */ + export const updateObjectBindingPattern = Debug.deprecate(factory.updateObjectBindingPattern, factoryDeprecation); + + /** @deprecated Use `factory.createArrayBindingPattern` or the factory supplied by your transformation context instead. */ + export const createArrayBindingPattern = Debug.deprecate(factory.createArrayBindingPattern, factoryDeprecation); + + /** @deprecated Use `factory.updateArrayBindingPattern` or the factory supplied by your transformation context instead. */ + export const updateArrayBindingPattern = Debug.deprecate(factory.updateArrayBindingPattern, factoryDeprecation); + + /** @deprecated Use `factory.createBindingElement` or the factory supplied by your transformation context instead. */ + export const createBindingElement = Debug.deprecate(factory.createBindingElement, factoryDeprecation); + + /** @deprecated Use `factory.updateBindingElement` or the factory supplied by your transformation context instead. */ + export const updateBindingElement = Debug.deprecate(factory.updateBindingElement, factoryDeprecation); + + /** @deprecated Use `factory.createArrayLiteralExpression` or the factory supplied by your transformation context instead. */ + export const createArrayLiteral = Debug.deprecate(factory.createArrayLiteralExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateArrayLiteralExpression` or the factory supplied by your transformation context instead. */ + export const updateArrayLiteral = Debug.deprecate(factory.updateArrayLiteralExpression, factoryDeprecation); + + /** @deprecated Use `factory.createObjectLiteralExpression` or the factory supplied by your transformation context instead. */ + export const createObjectLiteral = Debug.deprecate(factory.createObjectLiteralExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateObjectLiteralExpression` or the factory supplied by your transformation context instead. */ + export const updateObjectLiteral = Debug.deprecate(factory.updateObjectLiteralExpression, factoryDeprecation); + + /** @deprecated Use `factory.createPropertyAccessExpression` or the factory supplied by your transformation context instead. */ + export const createPropertyAccess = Debug.deprecate(factory.createPropertyAccessExpression, factoryDeprecation); + + /** @deprecated Use `factory.updatePropertyAccessExpression` or the factory supplied by your transformation context instead. */ + export const updatePropertyAccess = Debug.deprecate(factory.updatePropertyAccessExpression, factoryDeprecation); + + /** @deprecated Use `factory.createPropertyAccessChain` or the factory supplied by your transformation context instead. */ + export const createPropertyAccessChain = Debug.deprecate(factory.createPropertyAccessChain, factoryDeprecation); + + /** @deprecated Use `factory.updatePropertyAccessChain` or the factory supplied by your transformation context instead. */ + export const updatePropertyAccessChain = Debug.deprecate(factory.updatePropertyAccessChain, factoryDeprecation); + + /** @deprecated Use `factory.createElementAccessExpression` or the factory supplied by your transformation context instead. */ + export const createElementAccess = Debug.deprecate(factory.createElementAccessExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateElementAccessExpression` or the factory supplied by your transformation context instead. */ + export const updateElementAccess = Debug.deprecate(factory.updateElementAccessExpression, factoryDeprecation); + + /** @deprecated Use `factory.createElementAccessChain` or the factory supplied by your transformation context instead. */ + export const createElementAccessChain = Debug.deprecate(factory.createElementAccessChain, factoryDeprecation); + + /** @deprecated Use `factory.updateElementAccessChain` or the factory supplied by your transformation context instead. */ + export const updateElementAccessChain = Debug.deprecate(factory.updateElementAccessChain, factoryDeprecation); + + /** @deprecated Use `factory.createCallExpression` or the factory supplied by your transformation context instead. */ + export const createCall = Debug.deprecate(factory.createCallExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateCallExpression` or the factory supplied by your transformation context instead. */ + export const updateCall = Debug.deprecate(factory.updateCallExpression, factoryDeprecation); + + /** @deprecated Use `factory.createCallChain` or the factory supplied by your transformation context instead. */ + export const createCallChain = Debug.deprecate(factory.createCallChain, factoryDeprecation); + + /** @deprecated Use `factory.updateCallChain` or the factory supplied by your transformation context instead. */ + export const updateCallChain = Debug.deprecate(factory.updateCallChain, factoryDeprecation); + + /** @deprecated Use `factory.createNewExpression` or the factory supplied by your transformation context instead. */ + export const createNew = Debug.deprecate(factory.createNewExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateNewExpression` or the factory supplied by your transformation context instead. */ + export const updateNew = Debug.deprecate(factory.updateNewExpression, factoryDeprecation); + + /** @deprecated Use `factory.createTypeAssertion` or the factory supplied by your transformation context instead. */ + export const createTypeAssertion = Debug.deprecate(factory.createTypeAssertion, factoryDeprecation); + + /** @deprecated Use `factory.updateTypeAssertion` or the factory supplied by your transformation context instead. */ + export const updateTypeAssertion = Debug.deprecate(factory.updateTypeAssertion, factoryDeprecation); + + /** @deprecated Use `factory.createParenthesizedExpression` or the factory supplied by your transformation context instead. */ + export const createParen = Debug.deprecate(factory.createParenthesizedExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateParenthesizedExpression` or the factory supplied by your transformation context instead. */ + export const updateParen = Debug.deprecate(factory.updateParenthesizedExpression, factoryDeprecation); + + /** @deprecated Use `factory.createFunctionExpression` or the factory supplied by your transformation context instead. */ + export const createFunctionExpression = Debug.deprecate(factory.createFunctionExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateFunctionExpression` or the factory supplied by your transformation context instead. */ + export const updateFunctionExpression = Debug.deprecate(factory.updateFunctionExpression, factoryDeprecation); + + /** @deprecated Use `factory.createDeleteExpression` or the factory supplied by your transformation context instead. */ + export const createDelete = Debug.deprecate(factory.createDeleteExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateDeleteExpression` or the factory supplied by your transformation context instead. */ + export const updateDelete = Debug.deprecate(factory.updateDeleteExpression, factoryDeprecation); + + /** @deprecated Use `factory.createTypeOfExpression` or the factory supplied by your transformation context instead. */ + export const createTypeOf = Debug.deprecate(factory.createTypeOfExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateTypeOfExpression` or the factory supplied by your transformation context instead. */ + export const updateTypeOf = Debug.deprecate(factory.updateTypeOfExpression, factoryDeprecation); + + /** @deprecated Use `factory.createVoidExpression` or the factory supplied by your transformation context instead. */ + export const createVoid = Debug.deprecate(factory.createVoidExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateVoidExpression` or the factory supplied by your transformation context instead. */ + export const updateVoid = Debug.deprecate(factory.updateVoidExpression, factoryDeprecation); + + /** @deprecated Use `factory.createAwaitExpression` or the factory supplied by your transformation context instead. */ + export const createAwait = Debug.deprecate(factory.createAwaitExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateAwaitExpression` or the factory supplied by your transformation context instead. */ + export const updateAwait = Debug.deprecate(factory.updateAwaitExpression, factoryDeprecation); + + /** @deprecated Use `factory.createPrefixExpression` or the factory supplied by your transformation context instead. */ + export const createPrefix = Debug.deprecate(factory.createPrefixUnaryExpression, factoryDeprecation); + + /** @deprecated Use `factory.updatePrefixExpression` or the factory supplied by your transformation context instead. */ + export const updatePrefix = Debug.deprecate(factory.updatePrefixUnaryExpression, factoryDeprecation); + + /** @deprecated Use `factory.createPostfixUnaryExpression` or the factory supplied by your transformation context instead. */ + export const createPostfix = Debug.deprecate(factory.createPostfixUnaryExpression, factoryDeprecation); + + /** @deprecated Use `factory.updatePostfixUnaryExpression` or the factory supplied by your transformation context instead. */ + export const updatePostfix = Debug.deprecate(factory.updatePostfixUnaryExpression, factoryDeprecation); + + /** @deprecated Use `factory.createBinaryExpression` or the factory supplied by your transformation context instead. */ + export const createBinary = Debug.deprecate(factory.createBinaryExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateConditionalExpression` or the factory supplied by your transformation context instead. */ + export const updateConditional = Debug.deprecate(factory.updateConditionalExpression, factoryDeprecation); + + /** @deprecated Use `factory.createTemplateExpression` or the factory supplied by your transformation context instead. */ + export const createTemplateExpression = Debug.deprecate(factory.createTemplateExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateTemplateExpression` or the factory supplied by your transformation context instead. */ + export const updateTemplateExpression = Debug.deprecate(factory.updateTemplateExpression, factoryDeprecation); + + /** @deprecated Use `factory.createTemplateHead` or the factory supplied by your transformation context instead. */ + export const createTemplateHead = Debug.deprecate(factory.createTemplateHead, factoryDeprecation); + + /** @deprecated Use `factory.createTemplateMiddle` or the factory supplied by your transformation context instead. */ + export const createTemplateMiddle = Debug.deprecate(factory.createTemplateMiddle, factoryDeprecation); + + /** @deprecated Use `factory.createTemplateTail` or the factory supplied by your transformation context instead. */ + export const createTemplateTail = Debug.deprecate(factory.createTemplateTail, factoryDeprecation); + + /** @deprecated Use `factory.createNoSubstitutionTemplateLiteral` or the factory supplied by your transformation context instead. */ + export const createNoSubstitutionTemplateLiteral = Debug.deprecate(factory.createNoSubstitutionTemplateLiteral, factoryDeprecation); + + /** @deprecated Use `factory.updateYieldExpression` or the factory supplied by your transformation context instead. */ + export const updateYield = Debug.deprecate(factory.updateYieldExpression, factoryDeprecation); + + /** @deprecated Use `factory.createSpreadExpression` or the factory supplied by your transformation context instead. */ + export const createSpread = Debug.deprecate(factory.createSpreadElement, factoryDeprecation); + + /** @deprecated Use `factory.updateSpreadExpression` or the factory supplied by your transformation context instead. */ + export const updateSpread = Debug.deprecate(factory.updateSpreadElement, factoryDeprecation); + + /** @deprecated Use `factory.createOmittedExpression` or the factory supplied by your transformation context instead. */ + export const createOmittedExpression = Debug.deprecate(factory.createOmittedExpression, factoryDeprecation); + + /** @deprecated Use `factory.createAsExpression` or the factory supplied by your transformation context instead. */ + export const createAsExpression = Debug.deprecate(factory.createAsExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateAsExpression` or the factory supplied by your transformation context instead. */ + export const updateAsExpression = Debug.deprecate(factory.updateAsExpression, factoryDeprecation); + + /** @deprecated Use `factory.createNonNullExpression` or the factory supplied by your transformation context instead. */ + export const createNonNullExpression = Debug.deprecate(factory.createNonNullExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateNonNullExpression` or the factory supplied by your transformation context instead. */ + export const updateNonNullExpression = Debug.deprecate(factory.updateNonNullExpression, factoryDeprecation); + + /** @deprecated Use `factory.createNonNullChain` or the factory supplied by your transformation context instead. */ + export const createNonNullChain = Debug.deprecate(factory.createNonNullChain, factoryDeprecation); + + /** @deprecated Use `factory.updateNonNullChain` or the factory supplied by your transformation context instead. */ + export const updateNonNullChain = Debug.deprecate(factory.updateNonNullChain, factoryDeprecation); + + /** @deprecated Use `factory.createMetaProperty` or the factory supplied by your transformation context instead. */ + export const createMetaProperty = Debug.deprecate(factory.createMetaProperty, factoryDeprecation); + + /** @deprecated Use `factory.updateMetaProperty` or the factory supplied by your transformation context instead. */ + export const updateMetaProperty = Debug.deprecate(factory.updateMetaProperty, factoryDeprecation); + + /** @deprecated Use `factory.createTemplateSpan` or the factory supplied by your transformation context instead. */ + export const createTemplateSpan = Debug.deprecate(factory.createTemplateSpan, factoryDeprecation); + + /** @deprecated Use `factory.updateTemplateSpan` or the factory supplied by your transformation context instead. */ + export const updateTemplateSpan = Debug.deprecate(factory.updateTemplateSpan, factoryDeprecation); + + /** @deprecated Use `factory.createSemicolonClassElement` or the factory supplied by your transformation context instead. */ + export const createSemicolonClassElement = Debug.deprecate(factory.createSemicolonClassElement, factoryDeprecation); + + /** @deprecated Use `factory.createBlock` or the factory supplied by your transformation context instead. */ + export const createBlock = Debug.deprecate(factory.createBlock, factoryDeprecation); + + /** @deprecated Use `factory.updateBlock` or the factory supplied by your transformation context instead. */ + export const updateBlock = Debug.deprecate(factory.updateBlock, factoryDeprecation); + + /** @deprecated Use `factory.createVariableStatement` or the factory supplied by your transformation context instead. */ + export const createVariableStatement = Debug.deprecate(factory.createVariableStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateVariableStatement` or the factory supplied by your transformation context instead. */ + export const updateVariableStatement = Debug.deprecate(factory.updateVariableStatement, factoryDeprecation); + + /** @deprecated Use `factory.createEmptyStatement` or the factory supplied by your transformation context instead. */ + export const createEmptyStatement = Debug.deprecate(factory.createEmptyStatement, factoryDeprecation); + + /** @deprecated Use `factory.createExpressionStatement` or the factory supplied by your transformation context instead. */ + export const createExpressionStatement = Debug.deprecate(factory.createExpressionStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateExpressionStatement` or the factory supplied by your transformation context instead. */ + export const updateExpressionStatement = Debug.deprecate(factory.updateExpressionStatement, factoryDeprecation); + + /** @deprecated Use `factory.createExpressionStatement` or the factory supplied by your transformation context instead. */ + export const createStatement = Debug.deprecate(factory.createExpressionStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateExpressionStatement` or the factory supplied by your transformation context instead. */ + export const updateStatement = Debug.deprecate(factory.updateExpressionStatement, factoryDeprecation); + + /** @deprecated Use `factory.createIfStatement` or the factory supplied by your transformation context instead. */ + export const createIf = Debug.deprecate(factory.createIfStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateIfStatement` or the factory supplied by your transformation context instead. */ + export const updateIf = Debug.deprecate(factory.updateIfStatement, factoryDeprecation); + + /** @deprecated Use `factory.createDoStatement` or the factory supplied by your transformation context instead. */ + export const createDo = Debug.deprecate(factory.createDoStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateDoStatement` or the factory supplied by your transformation context instead. */ + export const updateDo = Debug.deprecate(factory.updateDoStatement, factoryDeprecation); + + /** @deprecated Use `factory.createWhileStatement` or the factory supplied by your transformation context instead. */ + export const createWhile = Debug.deprecate(factory.createWhileStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateWhileStatement` or the factory supplied by your transformation context instead. */ + export const updateWhile = Debug.deprecate(factory.updateWhileStatement, factoryDeprecation); + + /** @deprecated Use `factory.createForStatement` or the factory supplied by your transformation context instead. */ + export const createFor = Debug.deprecate(factory.createForStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateForStatement` or the factory supplied by your transformation context instead. */ + export const updateFor = Debug.deprecate(factory.updateForStatement, factoryDeprecation); + + /** @deprecated Use `factory.createForInStatement` or the factory supplied by your transformation context instead. */ + export const createForIn = Debug.deprecate(factory.createForInStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateForInStatement` or the factory supplied by your transformation context instead. */ + export const updateForIn = Debug.deprecate(factory.updateForInStatement, factoryDeprecation); + + /** @deprecated Use `factory.createForOfStatement` or the factory supplied by your transformation context instead. */ + export const createForOf = Debug.deprecate(factory.createForOfStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateForOfStatement` or the factory supplied by your transformation context instead. */ + export const updateForOf = Debug.deprecate(factory.updateForOfStatement, factoryDeprecation); + + /** @deprecated Use `factory.createContinueStatement` or the factory supplied by your transformation context instead. */ + export const createContinue = Debug.deprecate(factory.createContinueStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateContinueStatement` or the factory supplied by your transformation context instead. */ + export const updateContinue = Debug.deprecate(factory.updateContinueStatement, factoryDeprecation); + + /** @deprecated Use `factory.createBreakStatement` or the factory supplied by your transformation context instead. */ + export const createBreak = Debug.deprecate(factory.createBreakStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateBreakStatement` or the factory supplied by your transformation context instead. */ + export const updateBreak = Debug.deprecate(factory.updateBreakStatement, factoryDeprecation); + + /** @deprecated Use `factory.createReturnStatement` or the factory supplied by your transformation context instead. */ + export const createReturn = Debug.deprecate(factory.createReturnStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateReturnStatement` or the factory supplied by your transformation context instead. */ + export const updateReturn = Debug.deprecate(factory.updateReturnStatement, factoryDeprecation); + + /** @deprecated Use `factory.createWithStatement` or the factory supplied by your transformation context instead. */ + export const createWith = Debug.deprecate(factory.createWithStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateWithStatement` or the factory supplied by your transformation context instead. */ + export const updateWith = Debug.deprecate(factory.updateWithStatement, factoryDeprecation); + + /** @deprecated Use `factory.createSwitchStatement` or the factory supplied by your transformation context instead. */ + export const createSwitch = Debug.deprecate(factory.createSwitchStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateSwitchStatement` or the factory supplied by your transformation context instead. */ + export const updateSwitch = Debug.deprecate(factory.updateSwitchStatement, factoryDeprecation); + + /** @deprecated Use `factory.createLabelStatement` or the factory supplied by your transformation context instead. */ + export const createLabel = Debug.deprecate(factory.createLabeledStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateLabelStatement` or the factory supplied by your transformation context instead. */ + export const updateLabel = Debug.deprecate(factory.updateLabeledStatement, factoryDeprecation); + + /** @deprecated Use `factory.createThrowStatement` or the factory supplied by your transformation context instead. */ + export const createThrow = Debug.deprecate(factory.createThrowStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateThrowStatement` or the factory supplied by your transformation context instead. */ + export const updateThrow = Debug.deprecate(factory.updateThrowStatement, factoryDeprecation); + + /** @deprecated Use `factory.createTryStatement` or the factory supplied by your transformation context instead. */ + export const createTry = Debug.deprecate(factory.createTryStatement, factoryDeprecation); + + /** @deprecated Use `factory.updateTryStatement` or the factory supplied by your transformation context instead. */ + export const updateTry = Debug.deprecate(factory.updateTryStatement, factoryDeprecation); + + /** @deprecated Use `factory.createDebuggerStatement` or the factory supplied by your transformation context instead. */ + export const createDebuggerStatement = Debug.deprecate(factory.createDebuggerStatement, factoryDeprecation); + + /** @deprecated Use `factory.createVariableDeclarationList` or the factory supplied by your transformation context instead. */ + export const createVariableDeclarationList = Debug.deprecate(factory.createVariableDeclarationList, factoryDeprecation); + + /** @deprecated Use `factory.updateVariableDeclarationList` or the factory supplied by your transformation context instead. */ + export const updateVariableDeclarationList = Debug.deprecate(factory.updateVariableDeclarationList, factoryDeprecation); + + /** @deprecated Use `factory.createFunctionDeclaration` or the factory supplied by your transformation context instead. */ + export const createFunctionDeclaration = Debug.deprecate(factory.createFunctionDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateFunctionDeclaration` or the factory supplied by your transformation context instead. */ + export const updateFunctionDeclaration = Debug.deprecate(factory.updateFunctionDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createClassDeclaration` or the factory supplied by your transformation context instead. */ + export const createClassDeclaration = Debug.deprecate(factory.createClassDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateClassDeclaration` or the factory supplied by your transformation context instead. */ + export const updateClassDeclaration = Debug.deprecate(factory.updateClassDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createInterfaceDeclaration` or the factory supplied by your transformation context instead. */ + export const createInterfaceDeclaration = Debug.deprecate(factory.createInterfaceDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateInterfaceDeclaration` or the factory supplied by your transformation context instead. */ + export const updateInterfaceDeclaration = Debug.deprecate(factory.updateInterfaceDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createTypeAliasDeclaration` or the factory supplied by your transformation context instead. */ + export const createTypeAliasDeclaration = Debug.deprecate(factory.createTypeAliasDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateTypeAliasDeclaration` or the factory supplied by your transformation context instead. */ + export const updateTypeAliasDeclaration = Debug.deprecate(factory.updateTypeAliasDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createEnumDeclaration` or the factory supplied by your transformation context instead. */ + export const createEnumDeclaration = Debug.deprecate(factory.createEnumDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateEnumDeclaration` or the factory supplied by your transformation context instead. */ + export const updateEnumDeclaration = Debug.deprecate(factory.updateEnumDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createModuleDeclaration` or the factory supplied by your transformation context instead. */ + export const createModuleDeclaration = Debug.deprecate(factory.createModuleDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateModuleDeclaration` or the factory supplied by your transformation context instead. */ + export const updateModuleDeclaration = Debug.deprecate(factory.updateModuleDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createModuleBlock` or the factory supplied by your transformation context instead. */ + export const createModuleBlock = Debug.deprecate(factory.createModuleBlock, factoryDeprecation); + + /** @deprecated Use `factory.updateModuleBlock` or the factory supplied by your transformation context instead. */ + export const updateModuleBlock = Debug.deprecate(factory.updateModuleBlock, factoryDeprecation); + + /** @deprecated Use `factory.createCaseBlock` or the factory supplied by your transformation context instead. */ + export const createCaseBlock = Debug.deprecate(factory.createCaseBlock, factoryDeprecation); + + /** @deprecated Use `factory.updateCaseBlock` or the factory supplied by your transformation context instead. */ + export const updateCaseBlock = Debug.deprecate(factory.updateCaseBlock, factoryDeprecation); + + /** @deprecated Use `factory.createNamespaceExportDeclaration` or the factory supplied by your transformation context instead. */ + export const createNamespaceExportDeclaration = Debug.deprecate(factory.createNamespaceExportDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateNamespaceExportDeclaration` or the factory supplied by your transformation context instead. */ + export const updateNamespaceExportDeclaration = Debug.deprecate(factory.updateNamespaceExportDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createImportEqualsDeclaration` or the factory supplied by your transformation context instead. */ + export const createImportEqualsDeclaration = Debug.deprecate(factory.createImportEqualsDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateImportEqualsDeclaration` or the factory supplied by your transformation context instead. */ + export const updateImportEqualsDeclaration = Debug.deprecate(factory.updateImportEqualsDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createImportDeclaration` or the factory supplied by your transformation context instead. */ + export const createImportDeclaration = Debug.deprecate(factory.createImportDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.updateImportDeclaration` or the factory supplied by your transformation context instead. */ + export const updateImportDeclaration = Debug.deprecate(factory.updateImportDeclaration, factoryDeprecation); + + /** @deprecated Use `factory.createNamespaceImport` or the factory supplied by your transformation context instead. */ + export const createNamespaceImport = Debug.deprecate(factory.createNamespaceImport, factoryDeprecation); + + /** @deprecated Use `factory.updateNamespaceImport` or the factory supplied by your transformation context instead. */ + export const updateNamespaceImport = Debug.deprecate(factory.updateNamespaceImport, factoryDeprecation); + + /** @deprecated Use `factory.createNamedImports` or the factory supplied by your transformation context instead. */ + export const createNamedImports = Debug.deprecate(factory.createNamedImports, factoryDeprecation); + + /** @deprecated Use `factory.updateNamedImports` or the factory supplied by your transformation context instead. */ + export const updateNamedImports = Debug.deprecate(factory.updateNamedImports, factoryDeprecation); + + /** @deprecated Use `factory.createImportSpecifier` or the factory supplied by your transformation context instead. */ + export const createImportSpecifier = Debug.deprecate(factory.createImportSpecifier, factoryDeprecation); + + /** @deprecated Use `factory.updateImportSpecifier` or the factory supplied by your transformation context instead. */ + export const updateImportSpecifier = Debug.deprecate(factory.updateImportSpecifier, factoryDeprecation); + + /** @deprecated Use `factory.createExportAssignment` or the factory supplied by your transformation context instead. */ + export const createExportAssignment = Debug.deprecate(factory.createExportAssignment, factoryDeprecation); + + /** @deprecated Use `factory.updateExportAssignment` or the factory supplied by your transformation context instead. */ + export const updateExportAssignment = Debug.deprecate(factory.updateExportAssignment, factoryDeprecation); + + /** @deprecated Use `factory.createNamedExports` or the factory supplied by your transformation context instead. */ + export const createNamedExports = Debug.deprecate(factory.createNamedExports, factoryDeprecation); + + /** @deprecated Use `factory.updateNamedExports` or the factory supplied by your transformation context instead. */ + export const updateNamedExports = Debug.deprecate(factory.updateNamedExports, factoryDeprecation); + + /** @deprecated Use `factory.createExportSpecifier` or the factory supplied by your transformation context instead. */ + export const createExportSpecifier = Debug.deprecate(factory.createExportSpecifier, factoryDeprecation); + + /** @deprecated Use `factory.updateExportSpecifier` or the factory supplied by your transformation context instead. */ + export const updateExportSpecifier = Debug.deprecate(factory.updateExportSpecifier, factoryDeprecation); + + /** @deprecated Use `factory.createExternalModuleReference` or the factory supplied by your transformation context instead. */ + export const createExternalModuleReference = Debug.deprecate(factory.createExternalModuleReference, factoryDeprecation); + + /** @deprecated Use `factory.updateExternalModuleReference` or the factory supplied by your transformation context instead. */ + export const updateExternalModuleReference = Debug.deprecate(factory.updateExternalModuleReference, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocTypeExpression` or the factory supplied by your transformation context instead. */ + export const createJSDocTypeExpression = Debug.deprecate(factory.createJSDocTypeExpression, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocTypeTag` or the factory supplied by your transformation context instead. */ + export const createJSDocTypeTag = Debug.deprecate(factory.createJSDocTypeTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocReturnTag` or the factory supplied by your transformation context instead. */ + export const createJSDocReturnTag = Debug.deprecate(factory.createJSDocReturnTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocThisTag` or the factory supplied by your transformation context instead. */ + export const createJSDocThisTag = Debug.deprecate(factory.createJSDocThisTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocComment` or the factory supplied by your transformation context instead. */ + export const createJSDocComment = Debug.deprecate(factory.createJSDocComment, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ + export const createJSDocParameterTag = Debug.deprecate(factory.createJSDocParameterTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocClassTag` or the factory supplied by your transformation context instead. */ + export const createJSDocClassTag = Debug.deprecate(factory.createJSDocClassTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocAugmentsTag` or the factory supplied by your transformation context instead. */ + export const createJSDocAugmentsTag = Debug.deprecate(factory.createJSDocAugmentsTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocEnumTag` or the factory supplied by your transformation context instead. */ + export const createJSDocEnumTag = Debug.deprecate(factory.createJSDocEnumTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocTemplateTag` or the factory supplied by your transformation context instead. */ + export const createJSDocTemplateTag = Debug.deprecate(factory.createJSDocTemplateTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocTypedefTag` or the factory supplied by your transformation context instead. */ + export const createJSDocTypedefTag = Debug.deprecate(factory.createJSDocTypedefTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocCallbackTag` or the factory supplied by your transformation context instead. */ + export const createJSDocCallbackTag = Debug.deprecate(factory.createJSDocCallbackTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocSignature` or the factory supplied by your transformation context instead. */ + export const createJSDocSignature = Debug.deprecate(factory.createJSDocSignature, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocPropertyTag` or the factory supplied by your transformation context instead. */ + export const createJSDocPropertyTag = Debug.deprecate(factory.createJSDocPropertyTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocTypeLiteral` or the factory supplied by your transformation context instead. */ + export const createJSDocTypeLiteral = Debug.deprecate(factory.createJSDocTypeLiteral, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocImplementsTag` or the factory supplied by your transformation context instead. */ + export const createJSDocImplementsTag = Debug.deprecate(factory.createJSDocImplementsTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocAuthorTag` or the factory supplied by your transformation context instead. */ + export const createJSDocAuthorTag = Debug.deprecate(factory.createJSDocAuthorTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocPublicTag` or the factory supplied by your transformation context instead. */ + export const createJSDocPublicTag = Debug.deprecate(factory.createJSDocPublicTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocPrivateTag` or the factory supplied by your transformation context instead. */ + export const createJSDocPrivateTag = Debug.deprecate(factory.createJSDocPrivateTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocProtectedTag` or the factory supplied by your transformation context instead. */ + export const createJSDocProtectedTag = Debug.deprecate(factory.createJSDocProtectedTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocReadonlyTag` or the factory supplied by your transformation context instead. */ + export const createJSDocReadonlyTag = Debug.deprecate(factory.createJSDocReadonlyTag, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocUnknownTag` or the factory supplied by your transformation context instead. */ + export const createJSDocTag = Debug.deprecate(factory.createJSDocUnknownTag, factoryDeprecation); + + /** @deprecated Use `factory.createJsxElement` or the factory supplied by your transformation context instead. */ + export const createJsxElement = Debug.deprecate(factory.createJsxElement, factoryDeprecation); + + /** @deprecated Use `factory.updateJsxElement` or the factory supplied by your transformation context instead. */ + export const updateJsxElement = Debug.deprecate(factory.updateJsxElement, factoryDeprecation); + + /** @deprecated Use `factory.createJsxSelfClosingElement` or the factory supplied by your transformation context instead. */ + export const createJsxSelfClosingElement = Debug.deprecate(factory.createJsxSelfClosingElement, factoryDeprecation); + + /** @deprecated Use `factory.updateJsxSelfClosingElement` or the factory supplied by your transformation context instead. */ + export const updateJsxSelfClosingElement = Debug.deprecate(factory.updateJsxSelfClosingElement, factoryDeprecation); + + /** @deprecated Use `factory.createJsxOpeningElement` or the factory supplied by your transformation context instead. */ + export const createJsxOpeningElement = Debug.deprecate(factory.createJsxOpeningElement, factoryDeprecation); + + /** @deprecated Use `factory.updateJsxOpeningElement` or the factory supplied by your transformation context instead. */ + export const updateJsxOpeningElement = Debug.deprecate(factory.updateJsxOpeningElement, factoryDeprecation); + + /** @deprecated Use `factory.createJsxClosingElement` or the factory supplied by your transformation context instead. */ + export const createJsxClosingElement = Debug.deprecate(factory.createJsxClosingElement, factoryDeprecation); + + /** @deprecated Use `factory.updateJsxClosingElement` or the factory supplied by your transformation context instead. */ + export const updateJsxClosingElement = Debug.deprecate(factory.updateJsxClosingElement, factoryDeprecation); + + /** @deprecated Use `factory.createJsxFragment` or the factory supplied by your transformation context instead. */ + export const createJsxFragment = Debug.deprecate(factory.createJsxFragment, factoryDeprecation); + + /** @deprecated Use `factory.createJsxText` or the factory supplied by your transformation context instead. */ + export const createJsxText = Debug.deprecate(factory.createJsxText, factoryDeprecation); + + /** @deprecated Use `factory.updateJsxText` or the factory supplied by your transformation context instead. */ + export const updateJsxText = Debug.deprecate(factory.updateJsxText, factoryDeprecation); + + /** @deprecated Use `factory.createJsxOpeningFragment` or the factory supplied by your transformation context instead. */ + export const createJsxOpeningFragment = Debug.deprecate(factory.createJsxOpeningFragment, factoryDeprecation); + + /** @deprecated Use `factory.createJsxJsxClosingFragment` or the factory supplied by your transformation context instead. */ + export const createJsxJsxClosingFragment = Debug.deprecate(factory.createJsxJsxClosingFragment, factoryDeprecation); + + /** @deprecated Use `factory.updateJsxFragment` or the factory supplied by your transformation context instead. */ + export const updateJsxFragment = Debug.deprecate(factory.updateJsxFragment, factoryDeprecation); + + /** @deprecated Use `factory.createJsxAttribute` or the factory supplied by your transformation context instead. */ + export const createJsxAttribute = Debug.deprecate(factory.createJsxAttribute, factoryDeprecation); + + /** @deprecated Use `factory.updateJsxAttribute` or the factory supplied by your transformation context instead. */ + export const updateJsxAttribute = Debug.deprecate(factory.updateJsxAttribute, factoryDeprecation); + + /** @deprecated Use `factory.createJsxAttributes` or the factory supplied by your transformation context instead. */ + export const createJsxAttributes = Debug.deprecate(factory.createJsxAttributes, factoryDeprecation); + + /** @deprecated Use `factory.updateJsxAttributes` or the factory supplied by your transformation context instead. */ + export const updateJsxAttributes = Debug.deprecate(factory.updateJsxAttributes, factoryDeprecation); + + /** @deprecated Use `factory.createJsxSpreadAttribute` or the factory supplied by your transformation context instead. */ + export const createJsxSpreadAttribute = Debug.deprecate(factory.createJsxSpreadAttribute, factoryDeprecation); + + /** @deprecated Use `factory.updateJsxSpreadAttribute` or the factory supplied by your transformation context instead. */ + export const updateJsxSpreadAttribute = Debug.deprecate(factory.updateJsxSpreadAttribute, factoryDeprecation); + + /** @deprecated Use `factory.createJsxExpression` or the factory supplied by your transformation context instead. */ + export const createJsxExpression = Debug.deprecate(factory.createJsxExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateJsxExpression` or the factory supplied by your transformation context instead. */ + export const updateJsxExpression = Debug.deprecate(factory.updateJsxExpression, factoryDeprecation); + + /** @deprecated Use `factory.createCaseClause` or the factory supplied by your transformation context instead. */ + export const createCaseClause = Debug.deprecate(factory.createCaseClause, factoryDeprecation); + + /** @deprecated Use `factory.updateCaseClause` or the factory supplied by your transformation context instead. */ + export const updateCaseClause = Debug.deprecate(factory.updateCaseClause, factoryDeprecation); + + /** @deprecated Use `factory.createDefaultClause` or the factory supplied by your transformation context instead. */ + export const createDefaultClause = Debug.deprecate(factory.createDefaultClause, factoryDeprecation); + + /** @deprecated Use `factory.updateDefaultClause` or the factory supplied by your transformation context instead. */ + export const updateDefaultClause = Debug.deprecate(factory.updateDefaultClause, factoryDeprecation); + + /** @deprecated Use `factory.createHeritageClause` or the factory supplied by your transformation context instead. */ + export const createHeritageClause = Debug.deprecate(factory.createHeritageClause, factoryDeprecation); + + /** @deprecated Use `factory.updateHeritageClause` or the factory supplied by your transformation context instead. */ + export const updateHeritageClause = Debug.deprecate(factory.updateHeritageClause, factoryDeprecation); + + /** @deprecated Use `factory.createCatchClause` or the factory supplied by your transformation context instead. */ + export const createCatchClause = Debug.deprecate(factory.createCatchClause, factoryDeprecation); + + /** @deprecated Use `factory.updateCatchClause` or the factory supplied by your transformation context instead. */ + export const updateCatchClause = Debug.deprecate(factory.updateCatchClause, factoryDeprecation); + + /** @deprecated Use `factory.createPropertyAssignment` or the factory supplied by your transformation context instead. */ + export const createPropertyAssignment = Debug.deprecate(factory.createPropertyAssignment, factoryDeprecation); + + /** @deprecated Use `factory.updatePropertyAssignment` or the factory supplied by your transformation context instead. */ + export const updatePropertyAssignment = Debug.deprecate(factory.updatePropertyAssignment, factoryDeprecation); + + /** @deprecated Use `factory.createShorthandPropertyAssignment` or the factory supplied by your transformation context instead. */ + export const createShorthandPropertyAssignment = Debug.deprecate(factory.createShorthandPropertyAssignment, factoryDeprecation); + + /** @deprecated Use `factory.updateShorthandPropertyAssignment` or the factory supplied by your transformation context instead. */ + export const updateShorthandPropertyAssignment = Debug.deprecate(factory.updateShorthandPropertyAssignment, factoryDeprecation); + + /** @deprecated Use `factory.createSpreadAssignment` or the factory supplied by your transformation context instead. */ + export const createSpreadAssignment = Debug.deprecate(factory.createSpreadAssignment, factoryDeprecation); + + /** @deprecated Use `factory.updateSpreadAssignment` or the factory supplied by your transformation context instead. */ + export const updateSpreadAssignment = Debug.deprecate(factory.updateSpreadAssignment, factoryDeprecation); + + /** @deprecated Use `factory.createEnumMember` or the factory supplied by your transformation context instead. */ + export const createEnumMember = Debug.deprecate(factory.createEnumMember, factoryDeprecation); + + /** @deprecated Use `factory.updateEnumMember` or the factory supplied by your transformation context instead. */ + export const updateEnumMember = Debug.deprecate(factory.updateEnumMember, factoryDeprecation); + + /** @deprecated Use `factory.updateSourceFile` or the factory supplied by your transformation context instead. */ + export const updateSourceFileNode = Debug.deprecate(factory.updateSourceFile, factoryDeprecation); + + /** @deprecated Use `factory.createNotEmittedStatement` or the factory supplied by your transformation context instead. */ + export const createNotEmittedStatement = Debug.deprecate(factory.createNotEmittedStatement, factoryDeprecation); + + /** @deprecated Use `factory.createPartiallyEmittedExpression` or the factory supplied by your transformation context instead. */ + export const createPartiallyEmittedExpression = Debug.deprecate(factory.createPartiallyEmittedExpression, factoryDeprecation); + + /** @deprecated Use `factory.updatePartiallyEmittedExpression` or the factory supplied by your transformation context instead. */ + export const updatePartiallyEmittedExpression = Debug.deprecate(factory.updatePartiallyEmittedExpression, factoryDeprecation); + + /** @deprecated Use `factory.createCommaListExpression` or the factory supplied by your transformation context instead. */ + export const createCommaList = Debug.deprecate(factory.createCommaListExpression, factoryDeprecation); + + /** @deprecated Use `factory.updateCommaListExpression` or the factory supplied by your transformation context instead. */ + export const updateCommaList = Debug.deprecate(factory.updateCommaListExpression, factoryDeprecation); + + /** @deprecated Use `factory.createBundle` or the factory supplied by your transformation context instead. */ + export const createBundle = Debug.deprecate(factory.createBundle, factoryDeprecation); + + /** @deprecated Use `factory.updateBundle` or the factory supplied by your transformation context instead. */ + export const updateBundle = Debug.deprecate(factory.updateBundle, factoryDeprecation); + + /** @deprecated Use `factory.createImmediatelyInvokedFunctionExpression` or the factory supplied by your transformation context instead. */ + export const createImmediatelyInvokedFunctionExpression = Debug.deprecate(factory.createImmediatelyInvokedFunctionExpression, factoryDeprecation); + + /** @deprecated Use `factory.createImmediatelyInvokedArrowFunction` or the factory supplied by your transformation context instead. */ + export const createImmediatelyInvokedArrowFunction = Debug.deprecate(factory.createImmediatelyInvokedArrowFunction, factoryDeprecation); + + /** @deprecated Use `factory.createVoidZero` or the factory supplied by your transformation context instead. */ + export const createVoidZero = Debug.deprecate(factory.createVoidZero, factoryDeprecation); + + /** @deprecated Use `factory.createExportDefault` or the factory supplied by your transformation context instead. */ + export const createExportDefault = Debug.deprecate(factory.createExportDefault, factoryDeprecation); + + /** @deprecated Use `factory.createExternalModuleExport` or the factory supplied by your transformation context instead. */ + export const createExternalModuleExport = Debug.deprecate(factory.createExternalModuleExport, factoryDeprecation); + + /** @deprecated Use `factory.createNamespaceExport` or the factory supplied by your transformation context instead. */ + export const createNamespaceExport = Debug.deprecate(factory.createNamespaceExport, factoryDeprecation); + + /** @deprecated Use `factory.updateNamespaceExport` or the factory supplied by your transformation context instead. */ + export const updateNamespaceExport = Debug.deprecate(factory.updateNamespaceExport, factoryDeprecation); + + /** @deprecated Use `factory.createToken` or the factory supplied by your transformation context instead. */ + export const createToken = Debug.deprecate(function createToken(kind: TKind): Token { + return factory.createToken(kind); + }, factoryDeprecation); + + /** @deprecated Use `factory.createIdentifier` or the factory supplied by your transformation context instead. */ + export const createIdentifier = Debug.deprecate(function createIdentifier(text: string) { + return factory.createIdentifier(text, /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined); + }, factoryDeprecation); + + /** @deprecated Use `factory.createTempVariable` or the factory supplied by your transformation context instead. */ + export const createTempVariable = Debug.deprecate(function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier { + return factory.createTempVariable(recordTempVariable, /*reserveInNestedScopes*/ undefined); + }, factoryDeprecation); + + /** @deprecated Use `factory.getGeneratedNameForNode` or the factory supplied by your transformation context instead. */ + export const getGeneratedNameForNode = Debug.deprecate(function getGeneratedNameForNode(node: Node | undefined): Identifier { + return factory.getGeneratedNameForNode(node, /*flags*/ undefined); + }, factoryDeprecation); + + /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */ + export const createOptimisticUniqueName = Debug.deprecate(function createOptimisticUniqueName(text: string): Identifier { + return factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic); + }, factoryDeprecation); + + /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */ + export const createFileLevelUniqueName = Debug.deprecate(function createFileLevelUniqueName(text: string): Identifier { + return factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); + }, factoryDeprecation); + + /** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */ + export const createIndexSignature = Debug.deprecate(function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration { + return factory.createIndexSignature(decorators, modifiers, parameters, type); + }, factoryDeprecation); + + /** @deprecated Use `factory.createTypePredicateNode` or the factory supplied by your transformation context instead. */ + export const createTypePredicateNode = Debug.deprecate(function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode { + return factory.createTypePredicateNode(/*assertsModifier*/ undefined, parameterName, type); + }, factoryDeprecation); + + /** @deprecated Use `factory.updateTypePredicateNode` or the factory supplied by your transformation context instead. */ + export const updateTypePredicateNode = Debug.deprecate(function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode { + return factory.updateTypePredicateNode(node, /*assertsModifier*/ undefined, parameterName, type); + }, factoryDeprecation); + + /** @deprecated Use `factory.createStringLiteral`, `factory.createStringLiteralFromNode`, `factory.createNumericLiteral`, `factory.createBigIntLiteral`, `factory.createTrue`, `factory.createFalse`, or the factory supplied by your transformation context instead. */ + export const createLiteral = Debug.deprecate(function createLiteral(value: string | number | PseudoBigInt | boolean | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): PrimaryExpression { + if (typeof value === "number") { + return factory.createNumericLiteral(value); + } + // eslint-disable-next-line no-in-operator + if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt + return factory.createBigIntLiteral(value); + } + if (typeof value === "boolean") { + return value ? factory.createTrue() : factory.createFalse(); + } + if (typeof value === "string") { + return factory.createStringLiteral(value, /*isSingleQuote*/ undefined); + } + return factory.createStringLiteralFromNode(value); + } as { + (value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; + (value: number | PseudoBigInt): NumericLiteral; + (value: boolean): BooleanLiteral; + (value: string | number | PseudoBigInt | boolean): PrimaryExpression; + }, { since: "4.0", warnAfter: "4.1", message: "Use `factory.createStringLiteral`, `factory.createStringLiteralFromNode`, `factory.createNumericLiteral`, `factory.createBigIntLiteral`, `factory.createTrue`, `factory.createFalse`, or the factory supplied by your transformation context instead." }); + + /** @deprecated Use `factory.createMethodSignature` or the factory supplied by your transformation context instead. */ + export const createMethodSignature = Debug.deprecate(function createMethodSignature( + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: TypeNode | undefined, + name: string | PropertyName, + questionToken: QuestionToken | undefined + ) { + return factory.createMethodSignature(/*modifiers*/ undefined, name, questionToken, typeParameters, parameters, type); + }, factoryDeprecation); + + /** @deprecated Use `factory.updateMethodSignature` or the factory supplied by your transformation context instead. */ + export const updateMethodSignature = Debug.deprecate(function updateMethodSignature( + node: MethodSignature, + typeParameters: NodeArray | undefined, + parameters: NodeArray, + type: TypeNode | undefined, + name: PropertyName, + questionToken: QuestionToken | undefined + ) { + return factory.updateMethodSignature(node, node.modifiers, name, questionToken, typeParameters, parameters, type); + }, factoryDeprecation); + + /** @deprecated Use `factory.createTypeOperatorNode` or the factory supplied by your transformation context instead. */ + export const createTypeOperatorNode = Debug.deprecate(function createTypeOperatorNode(operatorOrType: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | TypeNode, type?: TypeNode) { + let operator: TypeOperatorNode["operator"]; + if (type) { + operator = operatorOrType as TypeOperatorNode["operator"]; + } + else { + type = operatorOrType as TypeNode; + operator = SyntaxKind.KeyOfKeyword; + } + return factory.createTypeOperatorNode(operator, type); + } as { + (type: TypeNode): TypeOperatorNode; + (operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode; + }, factoryDeprecation); + + /** @deprecated Use `factory.createTaggedTemplate` or the factory supplied by your transformation context instead. */ + export const createTaggedTemplate = Debug.deprecate(function createTaggedTemplate(tag: Expression, typeArgumentsOrTemplate: readonly TypeNode[] | TemplateLiteral | undefined, template?: TemplateLiteral) { + let typeArguments: readonly TypeNode[] | undefined; + if (template) { + typeArguments = typeArgumentsOrTemplate as readonly TypeNode[] | undefined; + } + else { + template = typeArgumentsOrTemplate as TemplateLiteral; + } + return factory.createTaggedTemplateExpression(tag, typeArguments, template); + } as { + (tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + (tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; + }, factoryDeprecation); + + /** @deprecated Use `factory.updateTaggedTemplate` or the factory supplied by your transformation context instead. */ + export const updateTaggedTemplate = Debug.deprecate(function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArgumentsOrTemplate: readonly TypeNode[] | TemplateLiteral | undefined, template?: TemplateLiteral) { + let typeArguments: readonly TypeNode[] | undefined; + if (template) { + typeArguments = typeArgumentsOrTemplate as readonly TypeNode[] | undefined; + } + else { + template = typeArgumentsOrTemplate as TemplateLiteral; + } + return factory.updateTaggedTemplateExpression(node, tag, typeArguments, template); + } as { + (node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; + (node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; + }, factoryDeprecation); + + /** @deprecated Use `factory.updateBinary` or the factory supplied by your transformation context instead. */ + export const updateBinary = Debug.deprecate(function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator: BinaryOperator | BinaryOperatorToken = node.operatorToken) { + if (typeof operator === "number") { + operator = operator === node.operatorToken.kind ? node.operatorToken : factory.createToken(operator); + } + return factory.updateBinaryExpression(node, left, operator, right); + }, factoryDeprecation); + + /** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */ + export const createConditional = Debug.deprecate(function createConditional(condition: Expression, questionTokenOrWhenTrue: QuestionToken | Expression, whenTrueOrWhenFalse: Expression, colonToken?: ColonToken, whenFalse?: Expression) { + return arguments.length === 5 ? factory.createConditionalExpression(condition, questionTokenOrWhenTrue as QuestionToken, whenTrueOrWhenFalse, colonToken, whenFalse!) : + arguments.length === 3 ? factory.createConditionalExpression(condition, factory.createToken(SyntaxKind.QuestionToken), questionTokenOrWhenTrue as Expression, factory.createToken(SyntaxKind.ColonToken), whenTrueOrWhenFalse) : + Debug.fail("Argument count mismatch"); + } as { + (condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; + (condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; + }, factoryDeprecation); + + /** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */ + export const createYield = Debug.deprecate(function createYield(asteriskTokenOrExpression?: AsteriskToken | Expression | undefined, expression?: Expression) { + let asteriskToken: AsteriskToken | undefined; + if (expression) { + asteriskToken = asteriskTokenOrExpression as AsteriskToken; + } + else { + expression = asteriskTokenOrExpression as Expression; + } + return factory.createYieldExpression(asteriskToken, expression); + } as { + (expression?: Expression | undefined): YieldExpression; + (asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; + }, factoryDeprecation); + + /** @deprecated Use `factory.createClassExpression` or the factory supplied by your transformation context instead. */ + export const createClassExpression = Debug.deprecate(function createClassExpression( + modifiers: readonly Modifier[] | undefined, + name: string | Identifier | undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + heritageClauses: readonly HeritageClause[] | undefined, + members: readonly ClassElement[] + ) { + return factory.createClassExpression(/*decorators*/ undefined, modifiers, name, typeParameters, heritageClauses, members); + }, factoryDeprecation); + + /** @deprecated Use `factory.updateClassExpression` or the factory supplied by your transformation context instead. */ + export const updateClassExpression = Debug.deprecate(function updateClassExpression( + node: ClassExpression, + modifiers: readonly Modifier[] | undefined, + name: Identifier | undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + heritageClauses: readonly HeritageClause[] | undefined, + members: readonly ClassElement[] + ) { + return factory.updateClassExpression(node, /*decorators*/ undefined, modifiers, name, typeParameters, heritageClauses, members); + }, factoryDeprecation); + + /** @deprecated Use `factory.createPropertySignature` or the factory supplied by your transformation context instead. */ + export const createPropertySignature = Debug.deprecate(function createPropertySignature( + modifiers: readonly Modifier[] | undefined, + name: PropertyName | string, + questionToken: QuestionToken | undefined, + type: TypeNode | undefined, + initializer?: Expression | undefined + ): PropertySignature { + const node = factory.createPropertySignature(modifiers, name, questionToken, type); + node.illegalInitializer = initializer; + return node; + }, factoryDeprecation); + + /** @deprecated Use `factory.updatePropertySignature` or the factory supplied by your transformation context instead. */ + export const updatePropertySignature = Debug.deprecate(function updatePropertySignature( + node: PropertySignature, + modifiers: readonly Modifier[] | undefined, + name: PropertyName, + questionToken: QuestionToken | undefined, + type: TypeNode | undefined, + initializer: Expression | undefined + ) { + let updated = factory.updatePropertySignature(node, modifiers, name, questionToken, type); + if (node.initializer !== initializer) { + if (updated === node) { + updated = factory.cloneNode(node); + } + updated.illegalInitializer = initializer; + } + return updated; + }, factoryDeprecation); + + /** @deprecated Use `factory.createExpressionWithTypeArguments` or the factory supplied by your transformation context instead. */ + export const createExpressionWithTypeArguments = Debug.deprecate(function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression) { + return factory.createExpressionWithTypeArguments(expression, typeArguments); + }, factoryDeprecation); + + /** @deprecated Use `factory.updateExpressionWithTypeArguments` or the factory supplied by your transformation context instead. */ + export const updateExpressionWithTypeArguments = Debug.deprecate(function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression) { + return factory.updateExpressionWithTypeArguments(node, expression, typeArguments); + }, factoryDeprecation); + + /** @deprecated Use `factory.createArrowFunction` or the factory supplied by your transformation context instead. */ + export const createArrowFunction = Debug.deprecate(function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanTokenOrBody: ConciseBody | EqualsGreaterThanToken | undefined, body?: ConciseBody) { + return arguments.length === 6 ? factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanTokenOrBody as EqualsGreaterThanToken | undefined, body!) : + arguments.length === 5 ? factory.createArrowFunction(modifiers, typeParameters, parameters, type, /*equalsGreaterThanToken*/ undefined, equalsGreaterThanTokenOrBody as ConciseBody) : + Debug.fail("Argument count mismatch"); + } as { + (modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; + (modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: ConciseBody): ArrowFunction; + }, factoryDeprecation); + + /** @deprecated Use `factory.updateArrowFunction` or the factory supplied by your transformation context instead. */ + export const updateArrowFunction = Debug.deprecate(function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanTokenOrBody: EqualsGreaterThanToken | ConciseBody, body?: ConciseBody) { + return arguments.length === 7 ? factory.updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanTokenOrBody as EqualsGreaterThanToken, body!) : + arguments.length === 6 ? factory.updateArrowFunction(node, modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, equalsGreaterThanTokenOrBody as ConciseBody) : + Debug.fail("Argument count mismatch"); + } as { + (node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; + (node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: ConciseBody): ArrowFunction; + }, factoryDeprecation); + + /** @deprecated Use `factory.createVariableDeclaration` or the factory supplied by your transformation context instead. */ + export const createVariableDeclaration = Debug.deprecate(function createVariableDeclaration(name: string | BindingName, exclamationTokenOrType?: ExclamationToken | TypeNode, typeOrInitializer?: TypeNode | Expression, initializer?: Expression) { + return arguments.length === 4 ? factory.createVariableDeclaration(name, exclamationTokenOrType as ExclamationToken | undefined, typeOrInitializer as TypeNode | undefined, initializer) : + arguments.length >= 1 && arguments.length <= 3 ? factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, exclamationTokenOrType as TypeNode | undefined, typeOrInitializer as Expression | undefined) : + Debug.fail("Argument count mismatch"); + } as { + (name: string | BindingName, type?: TypeNode | undefined, initializer?: Expression | undefined): VariableDeclaration; + (name: string | BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; + }, factoryDeprecation); + + /** @deprecated Use `factory.updateVariableDeclaration` or the factory supplied by your transformation context instead. */ + export const updateVariableDeclaration = Debug.deprecate(function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, exclamationTokenOrType: ExclamationToken | TypeNode | undefined, typeOrInitializer: TypeNode | Expression | undefined, initializer?: Expression | undefined) { + return arguments.length === 5 ? factory.updateVariableDeclaration(node, name, exclamationTokenOrType as ExclamationToken | undefined, typeOrInitializer as TypeNode | undefined, initializer) : + arguments.length === 4 ? factory.updateVariableDeclaration(node, name, node.exclamationToken, exclamationTokenOrType as TypeNode | undefined, typeOrInitializer as Expression | undefined) : + Debug.fail("Argument count mismatch"); + } as { + (node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; + (node: VariableDeclaration, name: BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; + }, factoryDeprecation); + + /** @deprecated Use `factory.createImportClause` or the factory supplied by your transformation context instead. */ + export const createImportClause = Debug.deprecate(function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined, isTypeOnly = false): ImportClause { + return factory.createImportClause(isTypeOnly, name, namedBindings); + }, factoryDeprecation); + + /** @deprecated Use `factory.updateImportClause` or the factory supplied by your transformation context instead. */ + export const updateImportClause = Debug.deprecate(function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined, isTypeOnly: boolean) { + return factory.updateImportClause(node, isTypeOnly, name, namedBindings); + }, factoryDeprecation); + + /** @deprecated Use `factory.createExportDeclaration` or the factory supplied by your transformation context instead. */ + export const createExportDeclaration = Debug.deprecate(function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression | undefined, isTypeOnly = false) { + return factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier); + }, factoryDeprecation); + + /** @deprecated Use `factory.updateExportDeclaration` or the factory supplied by your transformation context instead. */ + export const updateExportDeclaration = Debug.deprecate(function updateExportDeclaration( + node: ExportDeclaration, + decorators: readonly Decorator[] | undefined, + modifiers: readonly Modifier[] | undefined, + exportClause: NamedExportBindings | undefined, + moduleSpecifier: Expression | undefined, + isTypeOnly: boolean) { + return factory.updateExportDeclaration(node, decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, node.assertClause); + }, factoryDeprecation); + + /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ + export const createJSDocParamTag = Debug.deprecate(function createJSDocParamTag(name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, comment?: string | undefined): JSDocParameterTag { + return factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment ? factory.createNodeArray([factory.createJSDocText(comment)]) : undefined); + }, factoryDeprecation); + + /** @deprecated Use `factory.createComma` or the factory supplied by your transformation context instead. */ + export const createComma = Debug.deprecate(function createComma(left: Expression, right: Expression): Expression { + return factory.createComma(left, right); + }, factoryDeprecation); + + /** @deprecated Use `factory.createLessThan` or the factory supplied by your transformation context instead. */ + export const createLessThan = Debug.deprecate(function createLessThan(left: Expression, right: Expression): Expression { + return factory.createLessThan(left, right); + }, factoryDeprecation); + + /** @deprecated Use `factory.createAssignment` or the factory supplied by your transformation context instead. */ + export const createAssignment = Debug.deprecate(function createAssignment(left: Expression, right: Expression): BinaryExpression { + return factory.createAssignment(left, right); + }, factoryDeprecation); + + /** @deprecated Use `factory.createStrictEquality` or the factory supplied by your transformation context instead. */ + export const createStrictEquality = Debug.deprecate(function createStrictEquality(left: Expression, right: Expression): BinaryExpression { + return factory.createStrictEquality(left, right); + }, factoryDeprecation); + + /** @deprecated Use `factory.createStrictInequality` or the factory supplied by your transformation context instead. */ + export const createStrictInequality = Debug.deprecate(function createStrictInequality(left: Expression, right: Expression): BinaryExpression { + return factory.createStrictInequality(left, right); + }, factoryDeprecation); + + /** @deprecated Use `factory.createAdd` or the factory supplied by your transformation context instead. */ + export const createAdd = Debug.deprecate(function createAdd(left: Expression, right: Expression): BinaryExpression { + return factory.createAdd(left, right); + }, factoryDeprecation); + + /** @deprecated Use `factory.createSubtract` or the factory supplied by your transformation context instead. */ + export const createSubtract = Debug.deprecate(function createSubtract(left: Expression, right: Expression): BinaryExpression { + return factory.createSubtract(left, right); + }, factoryDeprecation); + + /** @deprecated Use `factory.createLogicalAnd` or the factory supplied by your transformation context instead. */ + export const createLogicalAnd = Debug.deprecate(function createLogicalAnd(left: Expression, right: Expression): BinaryExpression { + return factory.createLogicalAnd(left, right); + }, factoryDeprecation); + + /** @deprecated Use `factory.createLogicalOr` or the factory supplied by your transformation context instead. */ + export const createLogicalOr = Debug.deprecate(function createLogicalOr(left: Expression, right: Expression): BinaryExpression { + return factory.createLogicalOr(left, right); + }, factoryDeprecation); + + /** @deprecated Use `factory.createPostfixIncrement` or the factory supplied by your transformation context instead. */ + export const createPostfixIncrement = Debug.deprecate(function createPostfixIncrement(operand: Expression): PostfixUnaryExpression { + return factory.createPostfixIncrement(operand); + }, factoryDeprecation); + + /** @deprecated Use `factory.createLogicalNot` or the factory supplied by your transformation context instead. */ + export const createLogicalNot = Debug.deprecate(function createLogicalNot(operand: Expression): PrefixUnaryExpression { + return factory.createLogicalNot(operand); + }, factoryDeprecation); + + /** @deprecated Use an appropriate `factory` method instead. */ + export const createNode = Debug.deprecate(function createNode(kind: SyntaxKind, pos = 0, end = 0): Node { + return setTextRangePosEnd( + kind === SyntaxKind.SourceFile ? parseBaseNodeFactory.createBaseSourceFileNode(kind) : + kind === SyntaxKind.Identifier ? parseBaseNodeFactory.createBaseIdentifierNode(kind) : + kind === SyntaxKind.PrivateIdentifier ? parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : + !isNodeKind(kind) ? parseBaseNodeFactory.createBaseTokenNode(kind) : + parseBaseNodeFactory.createBaseNode(kind), + pos, + end + ); + }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); + + /** + * Creates a shallow, memberwise clone of a node ~for mutation~ with its `pos`, `end`, and `parent` set. + * + * NOTE: It is unsafe to change any properties of a `Node` that relate to its AST children, as those changes won't be + * captured with respect to transformations. + * + * @deprecated Use an appropriate `factory.update...` method instead, use `setCommentRange` or `setSourceMapRange`, and avoid setting `parent`. + */ + export const getMutableClone = Debug.deprecate(function getMutableClone(node: T): T { + const clone = factory.cloneNode(node); + setTextRange(clone, node); + setParent(clone, node.parent); + return clone; + }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory.update...` method instead, use `setCommentRange` or `setSourceMapRange`, and avoid setting `parent`." }); +} \ No newline at end of file diff --git a/src/deprecatedCompat/4.0/renamedMapInterfaces.ts b/src/deprecatedCompat/4.0/renamedMapInterfaces.ts new file mode 100644 index 0000000000000..127ac557c9ae1 --- /dev/null +++ b/src/deprecatedCompat/4.0/renamedMapInterfaces.ts @@ -0,0 +1,18 @@ +// DEPRECATION: Renamed `Map` and `ReadonlyMap` interfaces +// DEPRECATION PLAN: +// - soft: 4.0 +// - remove: TBD (will remove for at least one release before replacing with `ESMap`/`ReadonlyESMap`) +// - replace: TBD (will eventually replace with `ESMap`/`ReadonlyESMap`) +namespace ts { + /** + * @deprecated Use `ts.ReadonlyESMap` instead. + */ + export interface ReadonlyMap extends ReadonlyESMap { + } + + /** + * @deprecated Use `ts.ESMap` instead. + */ + export interface Map extends ESMap { + } +} \ No newline at end of file diff --git a/src/deprecatedCompat/4.0/renamedNodeTests.ts b/src/deprecatedCompat/4.0/renamedNodeTests.ts new file mode 100644 index 0000000000000..70db1312f7a9e --- /dev/null +++ b/src/deprecatedCompat/4.0/renamedNodeTests.ts @@ -0,0 +1,15 @@ +// DEPRECATION: Renamed node tests +// DEPRECATION PLAN: +// - soft: 4.0 +// - warn: 4.1 +// - error: TBD +namespace ts { + /** @deprecated Use `isTypeAssertionExpression` instead. */ + export const isTypeAssertion = Debug.deprecate(function isTypeAssertion(node: Node): node is TypeAssertion { + return node.kind === SyntaxKind.TypeAssertionExpression; + }, { + since: "4.0", + warnAfter: "4.1", + message: "Use `isTypeAssertionExpression` instead." + }); +} \ No newline at end of file diff --git a/src/deprecatedCompat/4.2/abstractConstructorTypes.ts b/src/deprecatedCompat/4.2/abstractConstructorTypes.ts new file mode 100644 index 0000000000000..f4db49abdcea2 --- /dev/null +++ b/src/deprecatedCompat/4.2/abstractConstructorTypes.ts @@ -0,0 +1,100 @@ +// DEPRECATION: Overloads for createConstructorTypeNode/updateConstructorTypeNode that do not accept 'modifiers' +// DEPRECATION PLAN: +// - soft: 4.2 +// - warn: 4.3 +// - error: 5.0 +namespace ts { + export interface NodeFactory { + /** @deprecated Use the overload that accepts 'modifiers' */ + createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; + + /** @deprecated Use the overload that accepts 'modifiers' */ + updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): ConstructorTypeNode; + } + + function patchNodeFactory(factory: NodeFactory) { + const createConstructorTypeNodeDeprecation = Debug.createDeprecation("createConstructorTypeNode", { since: "4.2", warnAfter: "4.3", message: "Use the overload that accepts 'modifiers'" }); + const prevCreateConstructorTypeNode = factory.createConstructorTypeNode; + factory.createConstructorTypeNode = createConstructorTypeNode; + + const updateConstructorTypeNodeDeprecation = Debug.createDeprecation("updateConstructorTypeNode", { since: "4.2", warnAfter: "4.3", message: "Use the overload that accepts 'modifiers'" }); + const prevUpdateConstructorTypeNode = factory.updateConstructorTypeNode; + factory.updateConstructorTypeNode = updateConstructorTypeNode; + + // @api + function createConstructorTypeNode(...args: Parameters | Parameters) { + return isCreateConstructorTypeNode1Args(args) ? + createConstructorTypeNode1(...args) : + createConstructorTypeNode2(...args); + } + + function isCreateConstructorTypeNode1Args(args: Parameters | Parameters): args is Parameters { + return args.length === 4; + } + + function createConstructorTypeNode1( + modifiers: readonly Modifier[] | undefined, + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: TypeNode + ): ConstructorTypeNode { + return prevCreateConstructorTypeNode(modifiers, typeParameters, parameters, type); + } + + /** @deprecated */ + function createConstructorTypeNode2( + typeParameters: readonly TypeParameterDeclaration[] | undefined, + parameters: readonly ParameterDeclaration[], + type: TypeNode + ): ConstructorTypeNode { + createConstructorTypeNodeDeprecation(); + return createConstructorTypeNode1(/*modifiers*/ undefined, typeParameters, parameters, type); + } + + function updateConstructorTypeNode(...args: Parameters | Parameters) { + return isUpdateConstructorTypeNode1Args(args) ? + updateConstructorTypeNode1(...args) : + updateConstructorTypeNode2(...args); + } + + function isUpdateConstructorTypeNode1Args(args: Parameters | Parameters): args is Parameters { + return args.length === 5; + } + + function updateConstructorTypeNode1( + node: ConstructorTypeNode, + modifiers: readonly Modifier[] | undefined, + typeParameters: NodeArray | undefined, + parameters: NodeArray, + type: TypeNode + ) { + return prevUpdateConstructorTypeNode(node, modifiers, typeParameters, parameters, type); + } + + /** @deprecated */ + function updateConstructorTypeNode2( + node: ConstructorTypeNode, + typeParameters: NodeArray | undefined, + parameters: NodeArray, + type: TypeNode + ) { + updateConstructorTypeNodeDeprecation(); + return updateConstructorTypeNode1(node, node.modifiers, typeParameters, parameters, type); + } + } + + // Patch `createNodeFactory` because it creates the factories that are provided to transformers + // in the public API. + + const prevCreateNodeFactory = createNodeFactory; + + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier + ts.createNodeFactory = (flags, baseFactory) => { + const factory = prevCreateNodeFactory(flags, baseFactory); + patchNodeFactory(factory); + return factory; + }; + + // Patch `ts.factory` because its public + patchNodeFactory(factory); +} \ No newline at end of file diff --git a/src/deprecatedCompat/4.2/renamedNodeTests.ts b/src/deprecatedCompat/4.2/renamedNodeTests.ts new file mode 100644 index 0000000000000..769f3d49b1154 --- /dev/null +++ b/src/deprecatedCompat/4.2/renamedNodeTests.ts @@ -0,0 +1,17 @@ +// DEPRECATION: Renamed node tests +// DEPRECATION PLAN: +// - soft: 4.2 +// - warn: 4.3 +// - error: 5.0 +namespace ts { + /** + * @deprecated Use `isMemberName` instead. + */ + export const isIdentifierOrPrivateIdentifier = Debug.deprecate(function isIdentifierOrPrivateIdentifier(node: Node): node is MemberName { + return isMemberName(node); + }, { + since: "4.2", + warnAfter: "4.3", + message: "Use `isMemberName` instead." + }); +} \ No newline at end of file diff --git a/src/deprecatedCompat/4.6/importTypeAssertions.ts b/src/deprecatedCompat/4.6/importTypeAssertions.ts new file mode 100644 index 0000000000000..15384eaf4a581 --- /dev/null +++ b/src/deprecatedCompat/4.6/importTypeAssertions.ts @@ -0,0 +1,96 @@ +// DEPRECATION: Overloads to createImportTypeNode/updateImportTypeNode that do not accept `assertions` +// DEPRECATION PLAN: +// - soft: 4.6 +// - warn: 4.7 +// - error: 5.0 +namespace ts { + export interface NodeFactory { + // NOTE: The following overload is not deprecated, but exists to ensure we don't mark `createImportTypeNode(argument)` as deprecated due to optional parameters. + createImportTypeNode(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + + /** @deprecated Use the overload that accepts 'assertions' */ + createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + + /** @deprecated Use the overload that accepts 'assertions' */ + updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode; + } + + function patchNodeFactory(factory: NodeFactory) { + const createImportTypeNodeDeprecation = Debug.createDeprecation("createImportTypeNode", { since: "4.6", warnAfter: "4.7", message: "Use the overload that accepts 'assertions'" }); + const prevCreateImportTypeNode = factory.createImportTypeNode; + factory.createImportTypeNode = createImportTypeNode; + + const updateImportTypeNodeDeprecation = Debug.createDeprecation("updateImportTypeNode", { since: "4.6", warnAfter: "4.7", message: "Use the overload that accepts 'assertions'" }); + const prevUpdateImportTypeNode = factory.updateImportTypeNode; + factory.updateImportTypeNode = updateImportTypeNode; + + function createImportTypeNode(...args: Parameters | Parameters) { + if (isCreateImportTypeNode1Args(args)) { + return createImportTypeNode1(...args); + } + else { + return createImportTypeNode2(...args); + } + } + + function isCreateImportTypeNode1Args(args: Parameters | Parameters): args is Parameters { + const [, assertions, qualifier, typeArguments] = args; + if (assertions !== undefined) return isImportTypeAssertionContainer(assertions); + if (qualifier !== undefined) return !isArray(qualifier); + if (typeArguments !== undefined) return isArray(typeArguments); + return true; + } + + function createImportTypeNode1(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode { + return prevCreateImportTypeNode(argument, assertions, qualifier, typeArguments, isTypeOf); + } + + /** @deprecated */ + function createImportTypeNode2(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode { + createImportTypeNodeDeprecation(); + return prevCreateImportTypeNode(argument, /*assertions*/ undefined, qualifier, typeArguments, isTypeOf); + } + + function updateImportTypeNode(...args: Parameters | Parameters) { + if (isUpdateImportTypeNode1Args(args)) { + return updateImportTypeNode1(...args); + } + else { + return updateImportTypeNode2(...args); + } + } + + function isUpdateImportTypeNode1Args(args: Parameters | Parameters): args is Parameters { + const [, , assertions, qualifier, typeArguments] = args; + if (assertions !== undefined) return isImportTypeAssertionContainer(assertions); + if (qualifier !== undefined) return !isArray(qualifier); + if (typeArguments !== undefined) return isArray(typeArguments); + return true; + } + + function updateImportTypeNode1(node: ImportTypeNode, argument: TypeNode, assertions: ImportTypeAssertionContainer | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode { + return prevUpdateImportTypeNode(node, argument, assertions, qualifier, typeArguments, isTypeOf); + } + + /** @deprecated */ + function updateImportTypeNode2(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode { + updateImportTypeNodeDeprecation(); + return prevUpdateImportTypeNode(node, argument, node.assertions, qualifier, typeArguments, isTypeOf); + } + } + + // Patch `createNodeFactory` because it creates the factories that are provided to transformers + // in the public API. + + const prevCreateNodeFactory = createNodeFactory; + + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier + ts.createNodeFactory = (flags, baseFactory) => { + const factory = prevCreateNodeFactory(flags, baseFactory); + patchNodeFactory(factory); + return factory; + }; + + // Patch `ts.factory` because its public + patchNodeFactory(factory); +} \ No newline at end of file diff --git a/src/deprecatedCompat/4.7/typeParameterModifiers.ts b/src/deprecatedCompat/4.7/typeParameterModifiers.ts new file mode 100644 index 0000000000000..46f6b275203ee --- /dev/null +++ b/src/deprecatedCompat/4.7/typeParameterModifiers.ts @@ -0,0 +1,85 @@ +// DEPRECATION: Overloads to createTypeParameter/updateTypeParameter that does not accept `modifiers` +// DEPRECATION PLAN: +// - soft: 4.7 +// - warn: 4.8 +// - error: 5.0 +namespace ts { + export interface NodeFactory { + /** @deprecated Use the overload that accepts 'modifiers' */ + createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; + + /** @deprecated Use the overload that accepts 'modifiers' */ + updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; + } + + function patchNodeFactory(factory: NodeFactory) { + const createTypeParameterDeclarationDeprecation = Debug.createDeprecation("createTypeParameterDeclaration", { since: "4.7", warnAfter: "4.8", message: "Use the overload that accepts 'modifiers'" }); + const prevCreateTypeParameterDeclaration = factory.createTypeParameterDeclaration; + factory.createTypeParameterDeclaration = createTypeParameterDeclaration; + + const updateTypeParameterDeclarationDeprecation = Debug.createDeprecation("updateTypeParameterDeclaration", { since: "4.7", warnAfter: "4.8", message: "Use the overload that accepts 'modifiers'" }); + const prevUpdateTypeParameterDeclaration = factory.updateTypeParameterDeclaration; + factory.updateTypeParameterDeclaration = updateTypeParameterDeclaration; + + function createTypeParameterDeclaration(...args: Parameters | Parameters) { + if (isCreateTypeParameterDeclaration1Args(args)) { + return createTypeParameterDeclaration1(...args); + } + else { + return createTypeParameterDeclaration2(...args); + } + } + + function isCreateTypeParameterDeclaration1Args(args: Parameters | Parameters): args is Parameters { + return args[0] === undefined || isArray(args[0]); + } + + function createTypeParameterDeclaration1(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration { + return prevCreateTypeParameterDeclaration(modifiers, name, constraint, defaultType); + } + + /** @deprecated */ + function createTypeParameterDeclaration2(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration { + createTypeParameterDeclarationDeprecation(); + return prevCreateTypeParameterDeclaration(/*modifiers*/ undefined, name, constraint, defaultType); + } + + function updateTypeParameterDeclaration(...args: Parameters | Parameters) { + if (isUpdateTypeParameterDeclaration1Args(args)) { + return updateTypeParameterDeclaration1(...args); + } + else { + return updateTypeParameterDeclaration2(...args); + } + } + + function isUpdateTypeParameterDeclaration1Args(args: Parameters | Parameters): args is Parameters { + return args[1] === undefined || isArray(args[1]); + } + + function updateTypeParameterDeclaration1(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration { + return prevUpdateTypeParameterDeclaration(node, modifiers, name, constraint, defaultType); + } + + /** @deprecated */ + function updateTypeParameterDeclaration2(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration { + updateTypeParameterDeclarationDeprecation(); + return prevUpdateTypeParameterDeclaration(node, node.modifiers, name, constraint, defaultType); + } + } + + // Patch `createNodeFactory` because it creates the factories that are provided to transformers + // in the public API. + + const prevCreateNodeFactory = createNodeFactory; + + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier + ts.createNodeFactory = (flags, baseFactory) => { + const factory = prevCreateNodeFactory(flags, baseFactory); + patchNodeFactory(factory); + return factory; + }; + + // Patch `ts.factory` because its public + patchNodeFactory(factory); +} \ No newline at end of file diff --git a/src/deprecatedCompat/4.8/mergeDecoratorsAndModifiers.ts b/src/deprecatedCompat/4.8/mergeDecoratorsAndModifiers.ts new file mode 100644 index 0000000000000..3a75b3030de7d --- /dev/null +++ b/src/deprecatedCompat/4.8/mergeDecoratorsAndModifiers.ts @@ -0,0 +1,394 @@ +// DEPRECATION: Deprecate passing `decorators` separate from `modifiers` +// DEPRECATION PLAN: +// - soft: 4.8 +// - warn: 4.9 +// - error: 5.0 +namespace ts { + export interface Node { + /** @deprecated `decorators` has been merged with `modifiers` on the declarations that support decorators. */ + readonly decorators?: readonly Decorator[] | undefined; + + /** @deprecated `modifiers` has been removed from `Node` and moved to the specific `Node` subtypes that support them. */ + readonly modifiers?: NodeArray | undefined; + } + + export interface PropertySignature { + /** @deprecated A property signature cannot have an initializer */ + readonly initializer?: undefined; + } + + export interface PropertyAssignment { + /** @deprecated A property assignment cannot have a question token */ + readonly questionToken?: undefined; + + /** @deprecated A property assignment cannot have an exclamation token */ + readonly exclamationToken?: undefined; + } + + export interface ShorthandPropertyAssignment { + /** @deprecated A shorthand property assignment cannot have a question token */ + readonly questionToken?: undefined; + + /** @deprecated A shorthand property assignment cannot have an exclamation token */ + readonly exclamationToken?: undefined; + + /** @deprecated A shorthand property assignment cannot have modifiers */ + readonly modifiers?: undefined; + } + + export interface NodeFactory { + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createPropertyDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updatePropertyDeclaration(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createMethodDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateMethodDeclaration(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createConstructorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateConstructorDeclaration(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createGetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateGetAccessorDeclaration(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createSetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateSetAccessorDeclaration(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createClassStaticBlockDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createClassExpression(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateClassExpression(node: ClassExpression, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause): ImportDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; + + } + + const functions = [ + { create: "createParameterDeclaration", update: "updateParameterDeclaration", mode: "must-merge" }, + { create: "createPropertyDeclaration", update: "updatePropertyDeclaration", mode: "must-merge" }, + { create: "createMethodDeclaration", update: "updateMethodDeclaration", mode: "must-merge" }, + { create: "createConstructorDeclaration", update: "updateConstructorDeclaration", mode: "disallow-decorators" }, + { create: "createGetAccessorDeclaration", update: "updateGetAccessorDeclaration", mode: "must-merge" }, + { create: "createSetAccessorDeclaration", update: "updateSetAccessorDeclaration", mode: "must-merge" }, + { create: "createIndexSignature", update: "updateIndexSignature", mode: "disallow-decorators" }, + { create: "createClassStaticBlockDeclaration", update: "updateClassStaticBlockDeclaration", mode: "disallow-decorators-and-modifiers" }, + { create: "createClassExpression", update: "updateClassExpression", mode: "must-merge" }, + { create: "createFunctionDeclaration", update: "updateFunctionDeclaration", mode: "disallow-decorators" }, + { create: "createClassDeclaration", update: "updateClassDeclaration", mode: "must-merge" }, + { create: "createInterfaceDeclaration", update: "updateInterfaceDeclaration", mode: "disallow-decorators" }, + { create: "createTypeAliasDeclaration", update: "updateTypeAliasDeclaration", mode: "disallow-decorators" }, + { create: "createEnumDeclaration", update: "updateEnumDeclaration", mode: "disallow-decorators" }, + { create: "createModuleDeclaration", update: "updateModuleDeclaration", mode: "disallow-decorators" }, + { create: "createImportEqualsDeclaration", update: "updateImportEqualsDeclaration", mode: "disallow-decorators" }, + { create: "createImportDeclaration", update: "updateImportDeclaration", mode: "disallow-decorators" }, + { create: "createExportAssignment", update: "updateExportAssignment", mode: "disallow-decorators" }, + { create: "createExportDeclaration", update: "updateExportDeclaration", mode: "disallow-decorators" }, + ] as const; + + interface CreateFunction { + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, ...args: any[]): any; + (decorators: null, modifiers: readonly ModifierLike[] | undefined | null, ...args: any[]): any; + }; + + interface UpdateFunction { + (node: Node, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, ...args: any[]): any; + (node: Node, decorators: null, modifiers: readonly ModifierLike[] | undefined | null, ...args: any[]): any; + }; + + const issuedDeprecations = new Set(); + + function handleDeprecation(deprecation: D, name: D["create"] | D["update"], decorators: readonly Decorator[] | null | undefined, modifiers: readonly ModifierLike[] | null | undefined) { + switch (deprecation.mode) { + case "disallow-decorators": + if (decorators) { + if (!issuedDeprecations.has(name)) { + issuedDeprecations.add(name); + Debug.createDeprecation(name, { since: "4.8", warnAfter: "4.9", message: `Decorators are no longer supported for this function. Callers should pass 'null' to the 'decorators' parameter so that a future update can introduce an overload that removes the parameter entirely.` })(); + } + } + return modifiers ?? undefined; + case "disallow-decorators-and-modifiers": + if (decorators || modifiers) { + if (!issuedDeprecations.has(name)) { + issuedDeprecations.add(name); + Debug.createDeprecation(name, { since: "4.8", warnAfter: "4.9", message: `Decorators and modifiers are no longer supported for this function. Callers should pass 'null' to both the 'decorators' and 'modifiers' parameters so that a future update can introduce an overload that removes these parameters entirely.` })(); + } + } + return RESERVED; + case "must-merge": + if (decorators !== RESERVED) { + if (!issuedDeprecations.has(name)) { + issuedDeprecations.add(name); + Debug.createDeprecation(name, { since: "4.8", warnAfter: "4.9", message: "Decorators have been combined with modifiers. Callers should pass 'null' to the 'decorators' parameter so that a future update can introduce an overload that removes the parameter entirely." })(); + } + } + return concatenate(decorators ?? undefined, modifiers ?? undefined); + } + } + + const decoratorsPropertyDeprecation = Debug.deprecate(function decorators(this: Node) { + if (canHaveDecorators(this)) { + return getDecorators(this); + } + if (canHaveIllegalDecorators(this)) { + return this.illegalDecorators; + } + }, { since: "4.8", warnAfter: "4.9", message: "The `decorators` property has been merged with `modifiers` and will be removed in a future update." }); + + function finishCreate(node: T) { + if (canHaveDecorators(node) || canHaveIllegalDecorators(node)) { + Object.defineProperty(node, "decorators", { + enumerable: true, + configurable: true, + get: decoratorsPropertyDeprecation + }); + } + return node; + } + + function finishUpdate(updated: T, original: T) { + if (updated !== original) { + return finishCreate(updated); + } + return updated; + } + + function patchCreateFunction(deprecation: D, create: F) { + return ((decorators, modifiers, ...args) => finishCreate(create(RESERVED, handleDeprecation(deprecation, deprecation.create, decorators, modifiers), ...args))) as F; + } + + function patchUpdateFunction(deprecation: D, update: F) { + return ((node, decorators, modifiers, ...args) => finishUpdate(update(node, RESERVED, handleDeprecation(deprecation, deprecation.create, decorators, modifiers), ...args), node)) as F; + } + + function patchFunctions(factory: NodeFactory, deprecation: D) { + factory[deprecation.create as D["create"]] = patchCreateFunction(deprecation, factory[deprecation.create as D["create"]]); + factory[deprecation.update as D["update"]] = patchUpdateFunction(deprecation, factory[deprecation.update as D["update"]]); + } + + function patchNodeFactory(factory: NodeFactory) { + for (const deprecation of functions) { + patchFunctions(factory, deprecation); + } + } + + // Patch `createNodeFactory` because it creates the factories that are provided to transformers + // in the public API. + + const prevCreateNodeFactory = createNodeFactory; + + // eslint-disable-next-line @typescript-eslint/no-unnecessary-qualifier + ts.createNodeFactory = (flags, baseFactory) => { + const factory = prevCreateNodeFactory(flags, baseFactory); + patchNodeFactory(factory); + return factory; + }; + + // Patch `ts.factory` because its public + patchNodeFactory(factory); +} diff --git a/src/deprecatedCompat/deprecations.ts b/src/deprecatedCompat/deprecations.ts index 98c47085f234d..ab6b7f94f4e63 100644 --- a/src/deprecatedCompat/deprecations.ts +++ b/src/deprecatedCompat/deprecations.ts @@ -1,1377 +1,11 @@ -namespace ts { - // The following are deprecations for the public API. Deprecated exports are removed from the compiler itself - // and compatible implementations are added here, along with an appropriate deprecation warning using - // the `@deprecated` JSDoc tag as well as the `Debug.deprecate` API. - // - // Deprecations fall into one of three categories: - // - // * "soft" - Soft deprecations are indicated with the `@deprecated` JSDoc Tag. - // * "warn" - Warning deprecations are indicated with the `@deprecated` JSDoc Tag and a diagnostic message (assuming a compatible host) - // * "error" - Error deprecations are indicated with the `@deprecated` JSDoc tag and will throw a `TypeError` when invoked. - - // DEPRECATION: Node factory top-level exports - // DEPRECATION PLAN: - // - soft: 4.0 - // - warn: 4.1 - // - error: TBD - // #region Node factory top-level exports - - // NOTE: These exports are deprecated in favor of using a `NodeFactory` instance and exist here purely for backwards compatibility reasons. - const factoryDeprecation: DeprecationOptions = { since: "4.0", warnAfter: "4.1", message: "Use the appropriate method on 'ts.factory' or the 'factory' supplied by your transformation context instead." }; - - /** @deprecated Use `factory.createNodeArray` or the factory supplied by your transformation context instead. */ - export const createNodeArray = Debug.deprecate(factory.createNodeArray, factoryDeprecation); - - /** @deprecated Use `factory.createNumericLiteral` or the factory supplied by your transformation context instead. */ - export const createNumericLiteral = Debug.deprecate(factory.createNumericLiteral, factoryDeprecation); - - /** @deprecated Use `factory.createBigIntLiteral` or the factory supplied by your transformation context instead. */ - export const createBigIntLiteral = Debug.deprecate(factory.createBigIntLiteral, factoryDeprecation); - - /** @deprecated Use `factory.createStringLiteral` or the factory supplied by your transformation context instead. */ - export const createStringLiteral = Debug.deprecate(factory.createStringLiteral, factoryDeprecation); - - /** @deprecated Use `factory.createStringLiteralFromNode` or the factory supplied by your transformation context instead. */ - export const createStringLiteralFromNode = Debug.deprecate(factory.createStringLiteralFromNode, factoryDeprecation); - - /** @deprecated Use `factory.createRegularExpressionLiteral` or the factory supplied by your transformation context instead. */ - export const createRegularExpressionLiteral = Debug.deprecate(factory.createRegularExpressionLiteral, factoryDeprecation); - - /** @deprecated Use `factory.createLoopVariable` or the factory supplied by your transformation context instead. */ - export const createLoopVariable = Debug.deprecate(factory.createLoopVariable, factoryDeprecation); - - /** @deprecated Use `factory.createUniqueName` or the factory supplied by your transformation context instead. */ - export const createUniqueName = Debug.deprecate(factory.createUniqueName, factoryDeprecation); - - /** @deprecated Use `factory.createPrivateIdentifier` or the factory supplied by your transformation context instead. */ - export const createPrivateIdentifier = Debug.deprecate(factory.createPrivateIdentifier, factoryDeprecation); - - /** @deprecated Use `factory.createSuper` or the factory supplied by your transformation context instead. */ - export const createSuper = Debug.deprecate(factory.createSuper, factoryDeprecation); - - /** @deprecated Use `factory.createThis` or the factory supplied by your transformation context instead. */ - export const createThis = Debug.deprecate(factory.createThis, factoryDeprecation); - - /** @deprecated Use `factory.createNull` or the factory supplied by your transformation context instead. */ - export const createNull = Debug.deprecate(factory.createNull, factoryDeprecation); - - /** @deprecated Use `factory.createTrue` or the factory supplied by your transformation context instead. */ - export const createTrue = Debug.deprecate(factory.createTrue, factoryDeprecation); - - /** @deprecated Use `factory.createFalse` or the factory supplied by your transformation context instead. */ - export const createFalse = Debug.deprecate(factory.createFalse, factoryDeprecation); - - /** @deprecated Use `factory.createModifier` or the factory supplied by your transformation context instead. */ - export const createModifier = Debug.deprecate(factory.createModifier, factoryDeprecation); - - /** @deprecated Use `factory.createModifiersFromModifierFlags` or the factory supplied by your transformation context instead. */ - export const createModifiersFromModifierFlags = Debug.deprecate(factory.createModifiersFromModifierFlags, factoryDeprecation); - - /** @deprecated Use `factory.createQualifiedName` or the factory supplied by your transformation context instead. */ - export const createQualifiedName = Debug.deprecate(factory.createQualifiedName, factoryDeprecation); - - /** @deprecated Use `factory.updateQualifiedName` or the factory supplied by your transformation context instead. */ - export const updateQualifiedName = Debug.deprecate(factory.updateQualifiedName, factoryDeprecation); - - /** @deprecated Use `factory.createComputedPropertyName` or the factory supplied by your transformation context instead. */ - export const createComputedPropertyName = Debug.deprecate(factory.createComputedPropertyName, factoryDeprecation); - - /** @deprecated Use `factory.updateComputedPropertyName` or the factory supplied by your transformation context instead. */ - export const updateComputedPropertyName = Debug.deprecate(factory.updateComputedPropertyName, factoryDeprecation); - - /** @deprecated Use `factory.createTypeParameterDeclaration` or the factory supplied by your transformation context instead. */ - export const createTypeParameterDeclaration = Debug.deprecate(factory.createTypeParameterDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateTypeParameterDeclaration` or the factory supplied by your transformation context instead. */ - export const updateTypeParameterDeclaration = Debug.deprecate(factory.updateTypeParameterDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createParameterDeclaration` or the factory supplied by your transformation context instead. */ - export const createParameter = Debug.deprecate(factory.createParameterDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateParameterDeclaration` or the factory supplied by your transformation context instead. */ - export const updateParameter = Debug.deprecate(factory.updateParameterDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createDecorator` or the factory supplied by your transformation context instead. */ - export const createDecorator = Debug.deprecate(factory.createDecorator, factoryDeprecation); - - /** @deprecated Use `factory.updateDecorator` or the factory supplied by your transformation context instead. */ - export const updateDecorator = Debug.deprecate(factory.updateDecorator, factoryDeprecation); - - /** @deprecated Use `factory.createPropertyDeclaration` or the factory supplied by your transformation context instead. */ - export const createProperty = Debug.deprecate(factory.createPropertyDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updatePropertyDeclaration` or the factory supplied by your transformation context instead. */ - export const updateProperty = Debug.deprecate(factory.updatePropertyDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createMethodDeclaration` or the factory supplied by your transformation context instead. */ - export const createMethod = Debug.deprecate(factory.createMethodDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateMethodDeclaration` or the factory supplied by your transformation context instead. */ - export const updateMethod = Debug.deprecate(factory.updateMethodDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createConstructorDeclaration` or the factory supplied by your transformation context instead. */ - export const createConstructor = Debug.deprecate(factory.createConstructorDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateConstructorDeclaration` or the factory supplied by your transformation context instead. */ - export const updateConstructor = Debug.deprecate(factory.updateConstructorDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createGetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - export const createGetAccessor = Debug.deprecate(factory.createGetAccessorDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateGetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - export const updateGetAccessor = Debug.deprecate(factory.updateGetAccessorDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createSetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - export const createSetAccessor = Debug.deprecate(factory.createSetAccessorDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateSetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - export const updateSetAccessor = Debug.deprecate(factory.updateSetAccessorDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createCallSignature` or the factory supplied by your transformation context instead. */ - export const createCallSignature = Debug.deprecate(factory.createCallSignature, factoryDeprecation); - - /** @deprecated Use `factory.updateCallSignature` or the factory supplied by your transformation context instead. */ - export const updateCallSignature = Debug.deprecate(factory.updateCallSignature, factoryDeprecation); - - /** @deprecated Use `factory.createConstructSignature` or the factory supplied by your transformation context instead. */ - export const createConstructSignature = Debug.deprecate(factory.createConstructSignature, factoryDeprecation); - - /** @deprecated Use `factory.updateConstructSignature` or the factory supplied by your transformation context instead. */ - export const updateConstructSignature = Debug.deprecate(factory.updateConstructSignature, factoryDeprecation); - - /** @deprecated Use `factory.updateIndexSignature` or the factory supplied by your transformation context instead. */ - export const updateIndexSignature = Debug.deprecate(factory.updateIndexSignature, factoryDeprecation); - - /** @deprecated Use `factory.createKeywordTypeNode` or the factory supplied by your transformation context instead. */ - export const createKeywordTypeNode = Debug.deprecate(factory.createKeywordTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createTypePredicateNode` or the factory supplied by your transformation context instead. */ - export const createTypePredicateNodeWithModifier = Debug.deprecate(factory.createTypePredicateNode, factoryDeprecation); - - /** @deprecated Use `factory.updateTypePredicateNode` or the factory supplied by your transformation context instead. */ - export const updateTypePredicateNodeWithModifier = Debug.deprecate(factory.updateTypePredicateNode, factoryDeprecation); - - /** @deprecated Use `factory.createTypeReferenceNode` or the factory supplied by your transformation context instead. */ - export const createTypeReferenceNode = Debug.deprecate(factory.createTypeReferenceNode, factoryDeprecation); - - /** @deprecated Use `factory.updateTypeReferenceNode` or the factory supplied by your transformation context instead. */ - export const updateTypeReferenceNode = Debug.deprecate(factory.updateTypeReferenceNode, factoryDeprecation); - - /** @deprecated Use `factory.createFunctionTypeNode` or the factory supplied by your transformation context instead. */ - export const createFunctionTypeNode = Debug.deprecate(factory.createFunctionTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateFunctionTypeNode` or the factory supplied by your transformation context instead. */ - export const updateFunctionTypeNode = Debug.deprecate(factory.updateFunctionTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createConstructorTypeNode` or the factory supplied by your transformation context instead. */ - export const createConstructorTypeNode = Debug.deprecate(( - typeParameters: readonly TypeParameterDeclaration[] | undefined, - parameters: readonly ParameterDeclaration[], - type: TypeNode - ) => { - return factory.createConstructorTypeNode(/*modifiers*/ undefined, typeParameters, parameters, type); - }, factoryDeprecation); - - /** @deprecated Use `factory.updateConstructorTypeNode` or the factory supplied by your transformation context instead. */ - export const updateConstructorTypeNode = Debug.deprecate(( - node: ConstructorTypeNode, - typeParameters: NodeArray | undefined, - parameters: NodeArray, - type: TypeNode - ) => { - return factory.updateConstructorTypeNode(node, node.modifiers, typeParameters, parameters, type); - }, factoryDeprecation); - - /** @deprecated Use `factory.createTypeQueryNode` or the factory supplied by your transformation context instead. */ - export const createTypeQueryNode = Debug.deprecate(factory.createTypeQueryNode, factoryDeprecation); - - /** @deprecated Use `factory.updateTypeQueryNode` or the factory supplied by your transformation context instead. */ - export const updateTypeQueryNode = Debug.deprecate(factory.updateTypeQueryNode, factoryDeprecation); - - /** @deprecated Use `factory.createTypeLiteralNode` or the factory supplied by your transformation context instead. */ - export const createTypeLiteralNode = Debug.deprecate(factory.createTypeLiteralNode, factoryDeprecation); - - /** @deprecated Use `factory.updateTypeLiteralNode` or the factory supplied by your transformation context instead. */ - export const updateTypeLiteralNode = Debug.deprecate(factory.updateTypeLiteralNode, factoryDeprecation); - - /** @deprecated Use `factory.createArrayTypeNode` or the factory supplied by your transformation context instead. */ - export const createArrayTypeNode = Debug.deprecate(factory.createArrayTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateArrayTypeNode` or the factory supplied by your transformation context instead. */ - export const updateArrayTypeNode = Debug.deprecate(factory.updateArrayTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createTupleTypeNode` or the factory supplied by your transformation context instead. */ - export const createTupleTypeNode = Debug.deprecate(factory.createTupleTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateTupleTypeNode` or the factory supplied by your transformation context instead. */ - export const updateTupleTypeNode = Debug.deprecate(factory.updateTupleTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createOptionalTypeNode` or the factory supplied by your transformation context instead. */ - export const createOptionalTypeNode = Debug.deprecate(factory.createOptionalTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateOptionalTypeNode` or the factory supplied by your transformation context instead. */ - export const updateOptionalTypeNode = Debug.deprecate(factory.updateOptionalTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createRestTypeNode` or the factory supplied by your transformation context instead. */ - export const createRestTypeNode = Debug.deprecate(factory.createRestTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateRestTypeNode` or the factory supplied by your transformation context instead. */ - export const updateRestTypeNode = Debug.deprecate(factory.updateRestTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createUnionTypeNode` or the factory supplied by your transformation context instead. */ - export const createUnionTypeNode = Debug.deprecate(factory.createUnionTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateUnionTypeNode` or the factory supplied by your transformation context instead. */ - export const updateUnionTypeNode = Debug.deprecate(factory.updateUnionTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createIntersectionTypeNode` or the factory supplied by your transformation context instead. */ - export const createIntersectionTypeNode = Debug.deprecate(factory.createIntersectionTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateIntersectionTypeNode` or the factory supplied by your transformation context instead. */ - export const updateIntersectionTypeNode = Debug.deprecate(factory.updateIntersectionTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createConditionalTypeNode` or the factory supplied by your transformation context instead. */ - export const createConditionalTypeNode = Debug.deprecate(factory.createConditionalTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateConditionalTypeNode` or the factory supplied by your transformation context instead. */ - export const updateConditionalTypeNode = Debug.deprecate(factory.updateConditionalTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createInferTypeNode` or the factory supplied by your transformation context instead. */ - export const createInferTypeNode = Debug.deprecate(factory.createInferTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateInferTypeNode` or the factory supplied by your transformation context instead. */ - export const updateInferTypeNode = Debug.deprecate(factory.updateInferTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createImportTypeNode` or the factory supplied by your transformation context instead. */ - export const createImportTypeNode = Debug.deprecate(factory.createImportTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateImportTypeNode` or the factory supplied by your transformation context instead. */ - export const updateImportTypeNode = Debug.deprecate(factory.updateImportTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createParenthesizedType` or the factory supplied by your transformation context instead. */ - export const createParenthesizedType = Debug.deprecate(factory.createParenthesizedType, factoryDeprecation); - - /** @deprecated Use `factory.updateParenthesizedType` or the factory supplied by your transformation context instead. */ - export const updateParenthesizedType = Debug.deprecate(factory.updateParenthesizedType, factoryDeprecation); - - /** @deprecated Use `factory.createThisTypeNode` or the factory supplied by your transformation context instead. */ - export const createThisTypeNode = Debug.deprecate(factory.createThisTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateTypeOperatorNode` or the factory supplied by your transformation context instead. */ - export const updateTypeOperatorNode = Debug.deprecate(factory.updateTypeOperatorNode, factoryDeprecation); - - /** @deprecated Use `factory.createIndexedAccessTypeNode` or the factory supplied by your transformation context instead. */ - export const createIndexedAccessTypeNode = Debug.deprecate(factory.createIndexedAccessTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateIndexedAccessTypeNode` or the factory supplied by your transformation context instead. */ - export const updateIndexedAccessTypeNode = Debug.deprecate(factory.updateIndexedAccessTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createMappedTypeNode` or the factory supplied by your transformation context instead. */ - export const createMappedTypeNode = Debug.deprecate(factory.createMappedTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateMappedTypeNode` or the factory supplied by your transformation context instead. */ - export const updateMappedTypeNode = Debug.deprecate(factory.updateMappedTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createLiteralTypeNode` or the factory supplied by your transformation context instead. */ - export const createLiteralTypeNode = Debug.deprecate(factory.createLiteralTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.updateLiteralTypeNode` or the factory supplied by your transformation context instead. */ - export const updateLiteralTypeNode = Debug.deprecate(factory.updateLiteralTypeNode, factoryDeprecation); - - /** @deprecated Use `factory.createObjectBindingPattern` or the factory supplied by your transformation context instead. */ - export const createObjectBindingPattern = Debug.deprecate(factory.createObjectBindingPattern, factoryDeprecation); - - /** @deprecated Use `factory.updateObjectBindingPattern` or the factory supplied by your transformation context instead. */ - export const updateObjectBindingPattern = Debug.deprecate(factory.updateObjectBindingPattern, factoryDeprecation); - - /** @deprecated Use `factory.createArrayBindingPattern` or the factory supplied by your transformation context instead. */ - export const createArrayBindingPattern = Debug.deprecate(factory.createArrayBindingPattern, factoryDeprecation); - - /** @deprecated Use `factory.updateArrayBindingPattern` or the factory supplied by your transformation context instead. */ - export const updateArrayBindingPattern = Debug.deprecate(factory.updateArrayBindingPattern, factoryDeprecation); - - /** @deprecated Use `factory.createBindingElement` or the factory supplied by your transformation context instead. */ - export const createBindingElement = Debug.deprecate(factory.createBindingElement, factoryDeprecation); - - /** @deprecated Use `factory.updateBindingElement` or the factory supplied by your transformation context instead. */ - export const updateBindingElement = Debug.deprecate(factory.updateBindingElement, factoryDeprecation); - - /** @deprecated Use `factory.createArrayLiteralExpression` or the factory supplied by your transformation context instead. */ - export const createArrayLiteral = Debug.deprecate(factory.createArrayLiteralExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateArrayLiteralExpression` or the factory supplied by your transformation context instead. */ - export const updateArrayLiteral = Debug.deprecate(factory.updateArrayLiteralExpression, factoryDeprecation); - - /** @deprecated Use `factory.createObjectLiteralExpression` or the factory supplied by your transformation context instead. */ - export const createObjectLiteral = Debug.deprecate(factory.createObjectLiteralExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateObjectLiteralExpression` or the factory supplied by your transformation context instead. */ - export const updateObjectLiteral = Debug.deprecate(factory.updateObjectLiteralExpression, factoryDeprecation); - - /** @deprecated Use `factory.createPropertyAccessExpression` or the factory supplied by your transformation context instead. */ - export const createPropertyAccess = Debug.deprecate(factory.createPropertyAccessExpression, factoryDeprecation); - - /** @deprecated Use `factory.updatePropertyAccessExpression` or the factory supplied by your transformation context instead. */ - export const updatePropertyAccess = Debug.deprecate(factory.updatePropertyAccessExpression, factoryDeprecation); - - /** @deprecated Use `factory.createPropertyAccessChain` or the factory supplied by your transformation context instead. */ - export const createPropertyAccessChain = Debug.deprecate(factory.createPropertyAccessChain, factoryDeprecation); - - /** @deprecated Use `factory.updatePropertyAccessChain` or the factory supplied by your transformation context instead. */ - export const updatePropertyAccessChain = Debug.deprecate(factory.updatePropertyAccessChain, factoryDeprecation); - - /** @deprecated Use `factory.createElementAccessExpression` or the factory supplied by your transformation context instead. */ - export const createElementAccess = Debug.deprecate(factory.createElementAccessExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateElementAccessExpression` or the factory supplied by your transformation context instead. */ - export const updateElementAccess = Debug.deprecate(factory.updateElementAccessExpression, factoryDeprecation); - - /** @deprecated Use `factory.createElementAccessChain` or the factory supplied by your transformation context instead. */ - export const createElementAccessChain = Debug.deprecate(factory.createElementAccessChain, factoryDeprecation); - - /** @deprecated Use `factory.updateElementAccessChain` or the factory supplied by your transformation context instead. */ - export const updateElementAccessChain = Debug.deprecate(factory.updateElementAccessChain, factoryDeprecation); - - /** @deprecated Use `factory.createCallExpression` or the factory supplied by your transformation context instead. */ - export const createCall = Debug.deprecate(factory.createCallExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateCallExpression` or the factory supplied by your transformation context instead. */ - export const updateCall = Debug.deprecate(factory.updateCallExpression, factoryDeprecation); - - /** @deprecated Use `factory.createCallChain` or the factory supplied by your transformation context instead. */ - export const createCallChain = Debug.deprecate(factory.createCallChain, factoryDeprecation); - - /** @deprecated Use `factory.updateCallChain` or the factory supplied by your transformation context instead. */ - export const updateCallChain = Debug.deprecate(factory.updateCallChain, factoryDeprecation); - - /** @deprecated Use `factory.createNewExpression` or the factory supplied by your transformation context instead. */ - export const createNew = Debug.deprecate(factory.createNewExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateNewExpression` or the factory supplied by your transformation context instead. */ - export const updateNew = Debug.deprecate(factory.updateNewExpression, factoryDeprecation); - - /** @deprecated Use `factory.createTypeAssertion` or the factory supplied by your transformation context instead. */ - export const createTypeAssertion = Debug.deprecate(factory.createTypeAssertion, factoryDeprecation); - - /** @deprecated Use `factory.updateTypeAssertion` or the factory supplied by your transformation context instead. */ - export const updateTypeAssertion = Debug.deprecate(factory.updateTypeAssertion, factoryDeprecation); - - /** @deprecated Use `factory.createParenthesizedExpression` or the factory supplied by your transformation context instead. */ - export const createParen = Debug.deprecate(factory.createParenthesizedExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateParenthesizedExpression` or the factory supplied by your transformation context instead. */ - export const updateParen = Debug.deprecate(factory.updateParenthesizedExpression, factoryDeprecation); - - /** @deprecated Use `factory.createFunctionExpression` or the factory supplied by your transformation context instead. */ - export const createFunctionExpression = Debug.deprecate(factory.createFunctionExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateFunctionExpression` or the factory supplied by your transformation context instead. */ - export const updateFunctionExpression = Debug.deprecate(factory.updateFunctionExpression, factoryDeprecation); - - /** @deprecated Use `factory.createDeleteExpression` or the factory supplied by your transformation context instead. */ - export const createDelete = Debug.deprecate(factory.createDeleteExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateDeleteExpression` or the factory supplied by your transformation context instead. */ - export const updateDelete = Debug.deprecate(factory.updateDeleteExpression, factoryDeprecation); - - /** @deprecated Use `factory.createTypeOfExpression` or the factory supplied by your transformation context instead. */ - export const createTypeOf = Debug.deprecate(factory.createTypeOfExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateTypeOfExpression` or the factory supplied by your transformation context instead. */ - export const updateTypeOf = Debug.deprecate(factory.updateTypeOfExpression, factoryDeprecation); - - /** @deprecated Use `factory.createVoidExpression` or the factory supplied by your transformation context instead. */ - export const createVoid = Debug.deprecate(factory.createVoidExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateVoidExpression` or the factory supplied by your transformation context instead. */ - export const updateVoid = Debug.deprecate(factory.updateVoidExpression, factoryDeprecation); - - /** @deprecated Use `factory.createAwaitExpression` or the factory supplied by your transformation context instead. */ - export const createAwait = Debug.deprecate(factory.createAwaitExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateAwaitExpression` or the factory supplied by your transformation context instead. */ - export const updateAwait = Debug.deprecate(factory.updateAwaitExpression, factoryDeprecation); - - /** @deprecated Use `factory.createPrefixExpression` or the factory supplied by your transformation context instead. */ - export const createPrefix = Debug.deprecate(factory.createPrefixUnaryExpression, factoryDeprecation); - - /** @deprecated Use `factory.updatePrefixExpression` or the factory supplied by your transformation context instead. */ - export const updatePrefix = Debug.deprecate(factory.updatePrefixUnaryExpression, factoryDeprecation); - - /** @deprecated Use `factory.createPostfixUnaryExpression` or the factory supplied by your transformation context instead. */ - export const createPostfix = Debug.deprecate(factory.createPostfixUnaryExpression, factoryDeprecation); - - /** @deprecated Use `factory.updatePostfixUnaryExpression` or the factory supplied by your transformation context instead. */ - export const updatePostfix = Debug.deprecate(factory.updatePostfixUnaryExpression, factoryDeprecation); - - /** @deprecated Use `factory.createBinaryExpression` or the factory supplied by your transformation context instead. */ - export const createBinary = Debug.deprecate(factory.createBinaryExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateConditionalExpression` or the factory supplied by your transformation context instead. */ - export const updateConditional = Debug.deprecate(factory.updateConditionalExpression, factoryDeprecation); - - /** @deprecated Use `factory.createTemplateExpression` or the factory supplied by your transformation context instead. */ - export const createTemplateExpression = Debug.deprecate(factory.createTemplateExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateTemplateExpression` or the factory supplied by your transformation context instead. */ - export const updateTemplateExpression = Debug.deprecate(factory.updateTemplateExpression, factoryDeprecation); - - /** @deprecated Use `factory.createTemplateHead` or the factory supplied by your transformation context instead. */ - export const createTemplateHead = Debug.deprecate(factory.createTemplateHead, factoryDeprecation); - - /** @deprecated Use `factory.createTemplateMiddle` or the factory supplied by your transformation context instead. */ - export const createTemplateMiddle = Debug.deprecate(factory.createTemplateMiddle, factoryDeprecation); - - /** @deprecated Use `factory.createTemplateTail` or the factory supplied by your transformation context instead. */ - export const createTemplateTail = Debug.deprecate(factory.createTemplateTail, factoryDeprecation); - - /** @deprecated Use `factory.createNoSubstitutionTemplateLiteral` or the factory supplied by your transformation context instead. */ - export const createNoSubstitutionTemplateLiteral = Debug.deprecate(factory.createNoSubstitutionTemplateLiteral, factoryDeprecation); - - /** @deprecated Use `factory.updateYieldExpression` or the factory supplied by your transformation context instead. */ - export const updateYield = Debug.deprecate(factory.updateYieldExpression, factoryDeprecation); - - /** @deprecated Use `factory.createSpreadExpression` or the factory supplied by your transformation context instead. */ - export const createSpread = Debug.deprecate(factory.createSpreadElement, factoryDeprecation); - - /** @deprecated Use `factory.updateSpreadExpression` or the factory supplied by your transformation context instead. */ - export const updateSpread = Debug.deprecate(factory.updateSpreadElement, factoryDeprecation); - - /** @deprecated Use `factory.createOmittedExpression` or the factory supplied by your transformation context instead. */ - export const createOmittedExpression = Debug.deprecate(factory.createOmittedExpression, factoryDeprecation); - - /** @deprecated Use `factory.createAsExpression` or the factory supplied by your transformation context instead. */ - export const createAsExpression = Debug.deprecate(factory.createAsExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateAsExpression` or the factory supplied by your transformation context instead. */ - export const updateAsExpression = Debug.deprecate(factory.updateAsExpression, factoryDeprecation); - - /** @deprecated Use `factory.createNonNullExpression` or the factory supplied by your transformation context instead. */ - export const createNonNullExpression = Debug.deprecate(factory.createNonNullExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateNonNullExpression` or the factory supplied by your transformation context instead. */ - export const updateNonNullExpression = Debug.deprecate(factory.updateNonNullExpression, factoryDeprecation); - - /** @deprecated Use `factory.createNonNullChain` or the factory supplied by your transformation context instead. */ - export const createNonNullChain = Debug.deprecate(factory.createNonNullChain, factoryDeprecation); - - /** @deprecated Use `factory.updateNonNullChain` or the factory supplied by your transformation context instead. */ - export const updateNonNullChain = Debug.deprecate(factory.updateNonNullChain, factoryDeprecation); - - /** @deprecated Use `factory.createMetaProperty` or the factory supplied by your transformation context instead. */ - export const createMetaProperty = Debug.deprecate(factory.createMetaProperty, factoryDeprecation); - - /** @deprecated Use `factory.updateMetaProperty` or the factory supplied by your transformation context instead. */ - export const updateMetaProperty = Debug.deprecate(factory.updateMetaProperty, factoryDeprecation); - - /** @deprecated Use `factory.createTemplateSpan` or the factory supplied by your transformation context instead. */ - export const createTemplateSpan = Debug.deprecate(factory.createTemplateSpan, factoryDeprecation); - - /** @deprecated Use `factory.updateTemplateSpan` or the factory supplied by your transformation context instead. */ - export const updateTemplateSpan = Debug.deprecate(factory.updateTemplateSpan, factoryDeprecation); - - /** @deprecated Use `factory.createSemicolonClassElement` or the factory supplied by your transformation context instead. */ - export const createSemicolonClassElement = Debug.deprecate(factory.createSemicolonClassElement, factoryDeprecation); - - /** @deprecated Use `factory.createBlock` or the factory supplied by your transformation context instead. */ - export const createBlock = Debug.deprecate(factory.createBlock, factoryDeprecation); - - /** @deprecated Use `factory.updateBlock` or the factory supplied by your transformation context instead. */ - export const updateBlock = Debug.deprecate(factory.updateBlock, factoryDeprecation); - - /** @deprecated Use `factory.createVariableStatement` or the factory supplied by your transformation context instead. */ - export const createVariableStatement = Debug.deprecate(factory.createVariableStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateVariableStatement` or the factory supplied by your transformation context instead. */ - export const updateVariableStatement = Debug.deprecate(factory.updateVariableStatement, factoryDeprecation); - - /** @deprecated Use `factory.createEmptyStatement` or the factory supplied by your transformation context instead. */ - export const createEmptyStatement = Debug.deprecate(factory.createEmptyStatement, factoryDeprecation); - - /** @deprecated Use `factory.createExpressionStatement` or the factory supplied by your transformation context instead. */ - export const createExpressionStatement = Debug.deprecate(factory.createExpressionStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateExpressionStatement` or the factory supplied by your transformation context instead. */ - export const updateExpressionStatement = Debug.deprecate(factory.updateExpressionStatement, factoryDeprecation); - - /** @deprecated Use `factory.createExpressionStatement` or the factory supplied by your transformation context instead. */ - export const createStatement = Debug.deprecate(factory.createExpressionStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateExpressionStatement` or the factory supplied by your transformation context instead. */ - export const updateStatement = Debug.deprecate(factory.updateExpressionStatement, factoryDeprecation); - - /** @deprecated Use `factory.createIfStatement` or the factory supplied by your transformation context instead. */ - export const createIf = Debug.deprecate(factory.createIfStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateIfStatement` or the factory supplied by your transformation context instead. */ - export const updateIf = Debug.deprecate(factory.updateIfStatement, factoryDeprecation); - - /** @deprecated Use `factory.createDoStatement` or the factory supplied by your transformation context instead. */ - export const createDo = Debug.deprecate(factory.createDoStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateDoStatement` or the factory supplied by your transformation context instead. */ - export const updateDo = Debug.deprecate(factory.updateDoStatement, factoryDeprecation); - - /** @deprecated Use `factory.createWhileStatement` or the factory supplied by your transformation context instead. */ - export const createWhile = Debug.deprecate(factory.createWhileStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateWhileStatement` or the factory supplied by your transformation context instead. */ - export const updateWhile = Debug.deprecate(factory.updateWhileStatement, factoryDeprecation); - - /** @deprecated Use `factory.createForStatement` or the factory supplied by your transformation context instead. */ - export const createFor = Debug.deprecate(factory.createForStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateForStatement` or the factory supplied by your transformation context instead. */ - export const updateFor = Debug.deprecate(factory.updateForStatement, factoryDeprecation); - - /** @deprecated Use `factory.createForInStatement` or the factory supplied by your transformation context instead. */ - export const createForIn = Debug.deprecate(factory.createForInStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateForInStatement` or the factory supplied by your transformation context instead. */ - export const updateForIn = Debug.deprecate(factory.updateForInStatement, factoryDeprecation); - - /** @deprecated Use `factory.createForOfStatement` or the factory supplied by your transformation context instead. */ - export const createForOf = Debug.deprecate(factory.createForOfStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateForOfStatement` or the factory supplied by your transformation context instead. */ - export const updateForOf = Debug.deprecate(factory.updateForOfStatement, factoryDeprecation); - - /** @deprecated Use `factory.createContinueStatement` or the factory supplied by your transformation context instead. */ - export const createContinue = Debug.deprecate(factory.createContinueStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateContinueStatement` or the factory supplied by your transformation context instead. */ - export const updateContinue = Debug.deprecate(factory.updateContinueStatement, factoryDeprecation); - - /** @deprecated Use `factory.createBreakStatement` or the factory supplied by your transformation context instead. */ - export const createBreak = Debug.deprecate(factory.createBreakStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateBreakStatement` or the factory supplied by your transformation context instead. */ - export const updateBreak = Debug.deprecate(factory.updateBreakStatement, factoryDeprecation); - - /** @deprecated Use `factory.createReturnStatement` or the factory supplied by your transformation context instead. */ - export const createReturn = Debug.deprecate(factory.createReturnStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateReturnStatement` or the factory supplied by your transformation context instead. */ - export const updateReturn = Debug.deprecate(factory.updateReturnStatement, factoryDeprecation); - - /** @deprecated Use `factory.createWithStatement` or the factory supplied by your transformation context instead. */ - export const createWith = Debug.deprecate(factory.createWithStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateWithStatement` or the factory supplied by your transformation context instead. */ - export const updateWith = Debug.deprecate(factory.updateWithStatement, factoryDeprecation); - - /** @deprecated Use `factory.createSwitchStatement` or the factory supplied by your transformation context instead. */ - export const createSwitch = Debug.deprecate(factory.createSwitchStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateSwitchStatement` or the factory supplied by your transformation context instead. */ - export const updateSwitch = Debug.deprecate(factory.updateSwitchStatement, factoryDeprecation); - - /** @deprecated Use `factory.createLabelStatement` or the factory supplied by your transformation context instead. */ - export const createLabel = Debug.deprecate(factory.createLabeledStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateLabelStatement` or the factory supplied by your transformation context instead. */ - export const updateLabel = Debug.deprecate(factory.updateLabeledStatement, factoryDeprecation); - - /** @deprecated Use `factory.createThrowStatement` or the factory supplied by your transformation context instead. */ - export const createThrow = Debug.deprecate(factory.createThrowStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateThrowStatement` or the factory supplied by your transformation context instead. */ - export const updateThrow = Debug.deprecate(factory.updateThrowStatement, factoryDeprecation); - - /** @deprecated Use `factory.createTryStatement` or the factory supplied by your transformation context instead. */ - export const createTry = Debug.deprecate(factory.createTryStatement, factoryDeprecation); - - /** @deprecated Use `factory.updateTryStatement` or the factory supplied by your transformation context instead. */ - export const updateTry = Debug.deprecate(factory.updateTryStatement, factoryDeprecation); - - /** @deprecated Use `factory.createDebuggerStatement` or the factory supplied by your transformation context instead. */ - export const createDebuggerStatement = Debug.deprecate(factory.createDebuggerStatement, factoryDeprecation); - - /** @deprecated Use `factory.createVariableDeclarationList` or the factory supplied by your transformation context instead. */ - export const createVariableDeclarationList = Debug.deprecate(factory.createVariableDeclarationList, factoryDeprecation); - - /** @deprecated Use `factory.updateVariableDeclarationList` or the factory supplied by your transformation context instead. */ - export const updateVariableDeclarationList = Debug.deprecate(factory.updateVariableDeclarationList, factoryDeprecation); - - /** @deprecated Use `factory.createFunctionDeclaration` or the factory supplied by your transformation context instead. */ - export const createFunctionDeclaration = Debug.deprecate(factory.createFunctionDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateFunctionDeclaration` or the factory supplied by your transformation context instead. */ - export const updateFunctionDeclaration = Debug.deprecate(factory.updateFunctionDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createClassDeclaration` or the factory supplied by your transformation context instead. */ - export const createClassDeclaration = Debug.deprecate(factory.createClassDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateClassDeclaration` or the factory supplied by your transformation context instead. */ - export const updateClassDeclaration = Debug.deprecate(factory.updateClassDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createInterfaceDeclaration` or the factory supplied by your transformation context instead. */ - export const createInterfaceDeclaration = Debug.deprecate(factory.createInterfaceDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateInterfaceDeclaration` or the factory supplied by your transformation context instead. */ - export const updateInterfaceDeclaration = Debug.deprecate(factory.updateInterfaceDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createTypeAliasDeclaration` or the factory supplied by your transformation context instead. */ - export const createTypeAliasDeclaration = Debug.deprecate(factory.createTypeAliasDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateTypeAliasDeclaration` or the factory supplied by your transformation context instead. */ - export const updateTypeAliasDeclaration = Debug.deprecate(factory.updateTypeAliasDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createEnumDeclaration` or the factory supplied by your transformation context instead. */ - export const createEnumDeclaration = Debug.deprecate(factory.createEnumDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateEnumDeclaration` or the factory supplied by your transformation context instead. */ - export const updateEnumDeclaration = Debug.deprecate(factory.updateEnumDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createModuleDeclaration` or the factory supplied by your transformation context instead. */ - export const createModuleDeclaration = Debug.deprecate(factory.createModuleDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateModuleDeclaration` or the factory supplied by your transformation context instead. */ - export const updateModuleDeclaration = Debug.deprecate(factory.updateModuleDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createModuleBlock` or the factory supplied by your transformation context instead. */ - export const createModuleBlock = Debug.deprecate(factory.createModuleBlock, factoryDeprecation); - - /** @deprecated Use `factory.updateModuleBlock` or the factory supplied by your transformation context instead. */ - export const updateModuleBlock = Debug.deprecate(factory.updateModuleBlock, factoryDeprecation); - - /** @deprecated Use `factory.createCaseBlock` or the factory supplied by your transformation context instead. */ - export const createCaseBlock = Debug.deprecate(factory.createCaseBlock, factoryDeprecation); - - /** @deprecated Use `factory.updateCaseBlock` or the factory supplied by your transformation context instead. */ - export const updateCaseBlock = Debug.deprecate(factory.updateCaseBlock, factoryDeprecation); - - /** @deprecated Use `factory.createNamespaceExportDeclaration` or the factory supplied by your transformation context instead. */ - export const createNamespaceExportDeclaration = Debug.deprecate(factory.createNamespaceExportDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateNamespaceExportDeclaration` or the factory supplied by your transformation context instead. */ - export const updateNamespaceExportDeclaration = Debug.deprecate(factory.updateNamespaceExportDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createImportEqualsDeclaration` or the factory supplied by your transformation context instead. */ - export const createImportEqualsDeclaration = Debug.deprecate(factory.createImportEqualsDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateImportEqualsDeclaration` or the factory supplied by your transformation context instead. */ - export const updateImportEqualsDeclaration = Debug.deprecate(factory.updateImportEqualsDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createImportDeclaration` or the factory supplied by your transformation context instead. */ - export const createImportDeclaration = Debug.deprecate(factory.createImportDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.updateImportDeclaration` or the factory supplied by your transformation context instead. */ - export const updateImportDeclaration = Debug.deprecate(factory.updateImportDeclaration, factoryDeprecation); - - /** @deprecated Use `factory.createNamespaceImport` or the factory supplied by your transformation context instead. */ - export const createNamespaceImport = Debug.deprecate(factory.createNamespaceImport, factoryDeprecation); - - /** @deprecated Use `factory.updateNamespaceImport` or the factory supplied by your transformation context instead. */ - export const updateNamespaceImport = Debug.deprecate(factory.updateNamespaceImport, factoryDeprecation); - - /** @deprecated Use `factory.createNamedImports` or the factory supplied by your transformation context instead. */ - export const createNamedImports = Debug.deprecate(factory.createNamedImports, factoryDeprecation); - - /** @deprecated Use `factory.updateNamedImports` or the factory supplied by your transformation context instead. */ - export const updateNamedImports = Debug.deprecate(factory.updateNamedImports, factoryDeprecation); - - /** @deprecated Use `factory.createImportSpecifier` or the factory supplied by your transformation context instead. */ - export const createImportSpecifier = Debug.deprecate(factory.createImportSpecifier, factoryDeprecation); - - /** @deprecated Use `factory.updateImportSpecifier` or the factory supplied by your transformation context instead. */ - export const updateImportSpecifier = Debug.deprecate(factory.updateImportSpecifier, factoryDeprecation); - - /** @deprecated Use `factory.createExportAssignment` or the factory supplied by your transformation context instead. */ - export const createExportAssignment = Debug.deprecate(factory.createExportAssignment, factoryDeprecation); - - /** @deprecated Use `factory.updateExportAssignment` or the factory supplied by your transformation context instead. */ - export const updateExportAssignment = Debug.deprecate(factory.updateExportAssignment, factoryDeprecation); - - /** @deprecated Use `factory.createNamedExports` or the factory supplied by your transformation context instead. */ - export const createNamedExports = Debug.deprecate(factory.createNamedExports, factoryDeprecation); - - /** @deprecated Use `factory.updateNamedExports` or the factory supplied by your transformation context instead. */ - export const updateNamedExports = Debug.deprecate(factory.updateNamedExports, factoryDeprecation); - - /** @deprecated Use `factory.createExportSpecifier` or the factory supplied by your transformation context instead. */ - export const createExportSpecifier = Debug.deprecate(factory.createExportSpecifier, factoryDeprecation); - - /** @deprecated Use `factory.updateExportSpecifier` or the factory supplied by your transformation context instead. */ - export const updateExportSpecifier = Debug.deprecate(factory.updateExportSpecifier, factoryDeprecation); - - /** @deprecated Use `factory.createExternalModuleReference` or the factory supplied by your transformation context instead. */ - export const createExternalModuleReference = Debug.deprecate(factory.createExternalModuleReference, factoryDeprecation); - - /** @deprecated Use `factory.updateExternalModuleReference` or the factory supplied by your transformation context instead. */ - export const updateExternalModuleReference = Debug.deprecate(factory.updateExternalModuleReference, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocTypeExpression` or the factory supplied by your transformation context instead. */ - export const createJSDocTypeExpression = Debug.deprecate(factory.createJSDocTypeExpression, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocTypeTag` or the factory supplied by your transformation context instead. */ - export const createJSDocTypeTag = Debug.deprecate(factory.createJSDocTypeTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocReturnTag` or the factory supplied by your transformation context instead. */ - export const createJSDocReturnTag = Debug.deprecate(factory.createJSDocReturnTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocThisTag` or the factory supplied by your transformation context instead. */ - export const createJSDocThisTag = Debug.deprecate(factory.createJSDocThisTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocComment` or the factory supplied by your transformation context instead. */ - export const createJSDocComment = Debug.deprecate(factory.createJSDocComment, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ - export const createJSDocParameterTag = Debug.deprecate(factory.createJSDocParameterTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocClassTag` or the factory supplied by your transformation context instead. */ - export const createJSDocClassTag = Debug.deprecate(factory.createJSDocClassTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocAugmentsTag` or the factory supplied by your transformation context instead. */ - export const createJSDocAugmentsTag = Debug.deprecate(factory.createJSDocAugmentsTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocEnumTag` or the factory supplied by your transformation context instead. */ - export const createJSDocEnumTag = Debug.deprecate(factory.createJSDocEnumTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocTemplateTag` or the factory supplied by your transformation context instead. */ - export const createJSDocTemplateTag = Debug.deprecate(factory.createJSDocTemplateTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocTypedefTag` or the factory supplied by your transformation context instead. */ - export const createJSDocTypedefTag = Debug.deprecate(factory.createJSDocTypedefTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocCallbackTag` or the factory supplied by your transformation context instead. */ - export const createJSDocCallbackTag = Debug.deprecate(factory.createJSDocCallbackTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocSignature` or the factory supplied by your transformation context instead. */ - export const createJSDocSignature = Debug.deprecate(factory.createJSDocSignature, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocPropertyTag` or the factory supplied by your transformation context instead. */ - export const createJSDocPropertyTag = Debug.deprecate(factory.createJSDocPropertyTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocTypeLiteral` or the factory supplied by your transformation context instead. */ - export const createJSDocTypeLiteral = Debug.deprecate(factory.createJSDocTypeLiteral, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocImplementsTag` or the factory supplied by your transformation context instead. */ - export const createJSDocImplementsTag = Debug.deprecate(factory.createJSDocImplementsTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocAuthorTag` or the factory supplied by your transformation context instead. */ - export const createJSDocAuthorTag = Debug.deprecate(factory.createJSDocAuthorTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocPublicTag` or the factory supplied by your transformation context instead. */ - export const createJSDocPublicTag = Debug.deprecate(factory.createJSDocPublicTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocPrivateTag` or the factory supplied by your transformation context instead. */ - export const createJSDocPrivateTag = Debug.deprecate(factory.createJSDocPrivateTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocProtectedTag` or the factory supplied by your transformation context instead. */ - export const createJSDocProtectedTag = Debug.deprecate(factory.createJSDocProtectedTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocReadonlyTag` or the factory supplied by your transformation context instead. */ - export const createJSDocReadonlyTag = Debug.deprecate(factory.createJSDocReadonlyTag, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocUnknownTag` or the factory supplied by your transformation context instead. */ - export const createJSDocTag = Debug.deprecate(factory.createJSDocUnknownTag, factoryDeprecation); - - /** @deprecated Use `factory.createJsxElement` or the factory supplied by your transformation context instead. */ - export const createJsxElement = Debug.deprecate(factory.createJsxElement, factoryDeprecation); - - /** @deprecated Use `factory.updateJsxElement` or the factory supplied by your transformation context instead. */ - export const updateJsxElement = Debug.deprecate(factory.updateJsxElement, factoryDeprecation); - - /** @deprecated Use `factory.createJsxSelfClosingElement` or the factory supplied by your transformation context instead. */ - export const createJsxSelfClosingElement = Debug.deprecate(factory.createJsxSelfClosingElement, factoryDeprecation); - - /** @deprecated Use `factory.updateJsxSelfClosingElement` or the factory supplied by your transformation context instead. */ - export const updateJsxSelfClosingElement = Debug.deprecate(factory.updateJsxSelfClosingElement, factoryDeprecation); - - /** @deprecated Use `factory.createJsxOpeningElement` or the factory supplied by your transformation context instead. */ - export const createJsxOpeningElement = Debug.deprecate(factory.createJsxOpeningElement, factoryDeprecation); - - /** @deprecated Use `factory.updateJsxOpeningElement` or the factory supplied by your transformation context instead. */ - export const updateJsxOpeningElement = Debug.deprecate(factory.updateJsxOpeningElement, factoryDeprecation); - - /** @deprecated Use `factory.createJsxClosingElement` or the factory supplied by your transformation context instead. */ - export const createJsxClosingElement = Debug.deprecate(factory.createJsxClosingElement, factoryDeprecation); - - /** @deprecated Use `factory.updateJsxClosingElement` or the factory supplied by your transformation context instead. */ - export const updateJsxClosingElement = Debug.deprecate(factory.updateJsxClosingElement, factoryDeprecation); - - /** @deprecated Use `factory.createJsxFragment` or the factory supplied by your transformation context instead. */ - export const createJsxFragment = Debug.deprecate(factory.createJsxFragment, factoryDeprecation); - - /** @deprecated Use `factory.createJsxText` or the factory supplied by your transformation context instead. */ - export const createJsxText = Debug.deprecate(factory.createJsxText, factoryDeprecation); - - /** @deprecated Use `factory.updateJsxText` or the factory supplied by your transformation context instead. */ - export const updateJsxText = Debug.deprecate(factory.updateJsxText, factoryDeprecation); - - /** @deprecated Use `factory.createJsxOpeningFragment` or the factory supplied by your transformation context instead. */ - export const createJsxOpeningFragment = Debug.deprecate(factory.createJsxOpeningFragment, factoryDeprecation); - - /** @deprecated Use `factory.createJsxJsxClosingFragment` or the factory supplied by your transformation context instead. */ - export const createJsxJsxClosingFragment = Debug.deprecate(factory.createJsxJsxClosingFragment, factoryDeprecation); - - /** @deprecated Use `factory.updateJsxFragment` or the factory supplied by your transformation context instead. */ - export const updateJsxFragment = Debug.deprecate(factory.updateJsxFragment, factoryDeprecation); - - /** @deprecated Use `factory.createJsxAttribute` or the factory supplied by your transformation context instead. */ - export const createJsxAttribute = Debug.deprecate(factory.createJsxAttribute, factoryDeprecation); - - /** @deprecated Use `factory.updateJsxAttribute` or the factory supplied by your transformation context instead. */ - export const updateJsxAttribute = Debug.deprecate(factory.updateJsxAttribute, factoryDeprecation); - - /** @deprecated Use `factory.createJsxAttributes` or the factory supplied by your transformation context instead. */ - export const createJsxAttributes = Debug.deprecate(factory.createJsxAttributes, factoryDeprecation); - - /** @deprecated Use `factory.updateJsxAttributes` or the factory supplied by your transformation context instead. */ - export const updateJsxAttributes = Debug.deprecate(factory.updateJsxAttributes, factoryDeprecation); - - /** @deprecated Use `factory.createJsxSpreadAttribute` or the factory supplied by your transformation context instead. */ - export const createJsxSpreadAttribute = Debug.deprecate(factory.createJsxSpreadAttribute, factoryDeprecation); - - /** @deprecated Use `factory.updateJsxSpreadAttribute` or the factory supplied by your transformation context instead. */ - export const updateJsxSpreadAttribute = Debug.deprecate(factory.updateJsxSpreadAttribute, factoryDeprecation); - - /** @deprecated Use `factory.createJsxExpression` or the factory supplied by your transformation context instead. */ - export const createJsxExpression = Debug.deprecate(factory.createJsxExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateJsxExpression` or the factory supplied by your transformation context instead. */ - export const updateJsxExpression = Debug.deprecate(factory.updateJsxExpression, factoryDeprecation); - - /** @deprecated Use `factory.createCaseClause` or the factory supplied by your transformation context instead. */ - export const createCaseClause = Debug.deprecate(factory.createCaseClause, factoryDeprecation); - - /** @deprecated Use `factory.updateCaseClause` or the factory supplied by your transformation context instead. */ - export const updateCaseClause = Debug.deprecate(factory.updateCaseClause, factoryDeprecation); - - /** @deprecated Use `factory.createDefaultClause` or the factory supplied by your transformation context instead. */ - export const createDefaultClause = Debug.deprecate(factory.createDefaultClause, factoryDeprecation); - - /** @deprecated Use `factory.updateDefaultClause` or the factory supplied by your transformation context instead. */ - export const updateDefaultClause = Debug.deprecate(factory.updateDefaultClause, factoryDeprecation); - - /** @deprecated Use `factory.createHeritageClause` or the factory supplied by your transformation context instead. */ - export const createHeritageClause = Debug.deprecate(factory.createHeritageClause, factoryDeprecation); - - /** @deprecated Use `factory.updateHeritageClause` or the factory supplied by your transformation context instead. */ - export const updateHeritageClause = Debug.deprecate(factory.updateHeritageClause, factoryDeprecation); - - /** @deprecated Use `factory.createCatchClause` or the factory supplied by your transformation context instead. */ - export const createCatchClause = Debug.deprecate(factory.createCatchClause, factoryDeprecation); - - /** @deprecated Use `factory.updateCatchClause` or the factory supplied by your transformation context instead. */ - export const updateCatchClause = Debug.deprecate(factory.updateCatchClause, factoryDeprecation); - - /** @deprecated Use `factory.createPropertyAssignment` or the factory supplied by your transformation context instead. */ - export const createPropertyAssignment = Debug.deprecate(factory.createPropertyAssignment, factoryDeprecation); - - /** @deprecated Use `factory.updatePropertyAssignment` or the factory supplied by your transformation context instead. */ - export const updatePropertyAssignment = Debug.deprecate(factory.updatePropertyAssignment, factoryDeprecation); - - /** @deprecated Use `factory.createShorthandPropertyAssignment` or the factory supplied by your transformation context instead. */ - export const createShorthandPropertyAssignment = Debug.deprecate(factory.createShorthandPropertyAssignment, factoryDeprecation); - - /** @deprecated Use `factory.updateShorthandPropertyAssignment` or the factory supplied by your transformation context instead. */ - export const updateShorthandPropertyAssignment = Debug.deprecate(factory.updateShorthandPropertyAssignment, factoryDeprecation); - - /** @deprecated Use `factory.createSpreadAssignment` or the factory supplied by your transformation context instead. */ - export const createSpreadAssignment = Debug.deprecate(factory.createSpreadAssignment, factoryDeprecation); - - /** @deprecated Use `factory.updateSpreadAssignment` or the factory supplied by your transformation context instead. */ - export const updateSpreadAssignment = Debug.deprecate(factory.updateSpreadAssignment, factoryDeprecation); - - /** @deprecated Use `factory.createEnumMember` or the factory supplied by your transformation context instead. */ - export const createEnumMember = Debug.deprecate(factory.createEnumMember, factoryDeprecation); - - /** @deprecated Use `factory.updateEnumMember` or the factory supplied by your transformation context instead. */ - export const updateEnumMember = Debug.deprecate(factory.updateEnumMember, factoryDeprecation); - - /** @deprecated Use `factory.updateSourceFile` or the factory supplied by your transformation context instead. */ - export const updateSourceFileNode = Debug.deprecate(factory.updateSourceFile, factoryDeprecation); - - /** @deprecated Use `factory.createNotEmittedStatement` or the factory supplied by your transformation context instead. */ - export const createNotEmittedStatement = Debug.deprecate(factory.createNotEmittedStatement, factoryDeprecation); - - /** @deprecated Use `factory.createPartiallyEmittedExpression` or the factory supplied by your transformation context instead. */ - export const createPartiallyEmittedExpression = Debug.deprecate(factory.createPartiallyEmittedExpression, factoryDeprecation); - - /** @deprecated Use `factory.updatePartiallyEmittedExpression` or the factory supplied by your transformation context instead. */ - export const updatePartiallyEmittedExpression = Debug.deprecate(factory.updatePartiallyEmittedExpression, factoryDeprecation); - - /** @deprecated Use `factory.createCommaListExpression` or the factory supplied by your transformation context instead. */ - export const createCommaList = Debug.deprecate(factory.createCommaListExpression, factoryDeprecation); - - /** @deprecated Use `factory.updateCommaListExpression` or the factory supplied by your transformation context instead. */ - export const updateCommaList = Debug.deprecate(factory.updateCommaListExpression, factoryDeprecation); - - /** @deprecated Use `factory.createBundle` or the factory supplied by your transformation context instead. */ - export const createBundle = Debug.deprecate(factory.createBundle, factoryDeprecation); - - /** @deprecated Use `factory.updateBundle` or the factory supplied by your transformation context instead. */ - export const updateBundle = Debug.deprecate(factory.updateBundle, factoryDeprecation); - - /** @deprecated Use `factory.createImmediatelyInvokedFunctionExpression` or the factory supplied by your transformation context instead. */ - export const createImmediatelyInvokedFunctionExpression = Debug.deprecate(factory.createImmediatelyInvokedFunctionExpression, factoryDeprecation); - - /** @deprecated Use `factory.createImmediatelyInvokedArrowFunction` or the factory supplied by your transformation context instead. */ - export const createImmediatelyInvokedArrowFunction = Debug.deprecate(factory.createImmediatelyInvokedArrowFunction, factoryDeprecation); - - /** @deprecated Use `factory.createVoidZero` or the factory supplied by your transformation context instead. */ - export const createVoidZero = Debug.deprecate(factory.createVoidZero, factoryDeprecation); - - /** @deprecated Use `factory.createExportDefault` or the factory supplied by your transformation context instead. */ - export const createExportDefault = Debug.deprecate(factory.createExportDefault, factoryDeprecation); - - /** @deprecated Use `factory.createExternalModuleExport` or the factory supplied by your transformation context instead. */ - export const createExternalModuleExport = Debug.deprecate(factory.createExternalModuleExport, factoryDeprecation); - - /** @deprecated Use `factory.createNamespaceExport` or the factory supplied by your transformation context instead. */ - export const createNamespaceExport = Debug.deprecate(factory.createNamespaceExport, factoryDeprecation); - - /** @deprecated Use `factory.updateNamespaceExport` or the factory supplied by your transformation context instead. */ - export const updateNamespaceExport = Debug.deprecate(factory.updateNamespaceExport, factoryDeprecation); - - /** @deprecated Use `factory.createToken` or the factory supplied by your transformation context instead. */ - export const createToken = Debug.deprecate(function createToken(kind: TKind): Token { - return factory.createToken(kind); - }, factoryDeprecation); - - /** @deprecated Use `factory.createIdentifier` or the factory supplied by your transformation context instead. */ - export const createIdentifier = Debug.deprecate(function createIdentifier(text: string) { - return factory.createIdentifier(text, /*typeArguments*/ undefined, /*originalKeywordKind*/ undefined); - }, factoryDeprecation); - - /** @deprecated Use `factory.createTempVariable` or the factory supplied by your transformation context instead. */ - export const createTempVariable = Debug.deprecate(function createTempVariable(recordTempVariable: ((node: Identifier) => void) | undefined): Identifier { - return factory.createTempVariable(recordTempVariable, /*reserveInNestedScopes*/ undefined); - }, factoryDeprecation); - - /** @deprecated Use `factory.getGeneratedNameForNode` or the factory supplied by your transformation context instead. */ - export const getGeneratedNameForNode = Debug.deprecate(function getGeneratedNameForNode(node: Node | undefined): Identifier { - return factory.getGeneratedNameForNode(node, /*flags*/ undefined); - }, factoryDeprecation); - - /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic)` or the factory supplied by your transformation context instead. */ - export const createOptimisticUniqueName = Debug.deprecate(function createOptimisticUniqueName(text: string): Identifier { - return factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic); - }, factoryDeprecation); - - /** @deprecated Use `factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel)` or the factory supplied by your transformation context instead. */ - export const createFileLevelUniqueName = Debug.deprecate(function createFileLevelUniqueName(text: string): Identifier { - return factory.createUniqueName(text, GeneratedIdentifierFlags.Optimistic | GeneratedIdentifierFlags.FileLevel); - }, factoryDeprecation); - - /** @deprecated Use `factory.createIndexSignature` or the factory supplied by your transformation context instead. */ - export const createIndexSignature = Debug.deprecate(function createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration { - return factory.createIndexSignature(decorators, modifiers, parameters, type); - }, factoryDeprecation); - - /** @deprecated Use `factory.createTypePredicateNode` or the factory supplied by your transformation context instead. */ - export const createTypePredicateNode = Debug.deprecate(function createTypePredicateNode(parameterName: Identifier | ThisTypeNode | string, type: TypeNode): TypePredicateNode { - return factory.createTypePredicateNode(/*assertsModifier*/ undefined, parameterName, type); - }, factoryDeprecation); - - /** @deprecated Use `factory.updateTypePredicateNode` or the factory supplied by your transformation context instead. */ - export const updateTypePredicateNode = Debug.deprecate(function updateTypePredicateNode(node: TypePredicateNode, parameterName: Identifier | ThisTypeNode, type: TypeNode): TypePredicateNode { - return factory.updateTypePredicateNode(node, /*assertsModifier*/ undefined, parameterName, type); - }, factoryDeprecation); - - /** @deprecated Use `factory.createStringLiteral`, `factory.createStringLiteralFromNode`, `factory.createNumericLiteral`, `factory.createBigIntLiteral`, `factory.createTrue`, `factory.createFalse`, or the factory supplied by your transformation context instead. */ - export const createLiteral = Debug.deprecate(function createLiteral(value: string | number | PseudoBigInt | boolean | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): PrimaryExpression { - if (typeof value === "number") { - return factory.createNumericLiteral(value); - } - // eslint-disable-next-line no-in-operator - if (typeof value === "object" && "base10Value" in value) { // PseudoBigInt - return factory.createBigIntLiteral(value); - } - if (typeof value === "boolean") { - return value ? factory.createTrue() : factory.createFalse(); - } - if (typeof value === "string") { - return factory.createStringLiteral(value, /*isSingleQuote*/ undefined); - } - return factory.createStringLiteralFromNode(value); - } as { - (value: string | StringLiteral | NoSubstitutionTemplateLiteral | NumericLiteral | Identifier): StringLiteral; - (value: number | PseudoBigInt): NumericLiteral; - (value: boolean): BooleanLiteral; - (value: string | number | PseudoBigInt | boolean): PrimaryExpression; - }, { since: "4.0", warnAfter: "4.1", message: "Use `factory.createStringLiteral`, `factory.createStringLiteralFromNode`, `factory.createNumericLiteral`, `factory.createBigIntLiteral`, `factory.createTrue`, `factory.createFalse`, or the factory supplied by your transformation context instead." }); - - /** @deprecated Use `factory.createMethodSignature` or the factory supplied by your transformation context instead. */ - export const createMethodSignature = Debug.deprecate(function createMethodSignature( - typeParameters: readonly TypeParameterDeclaration[] | undefined, - parameters: readonly ParameterDeclaration[], - type: TypeNode | undefined, - name: string | PropertyName, - questionToken: QuestionToken | undefined - ) { - return factory.createMethodSignature(/*modifiers*/ undefined, name, questionToken, typeParameters, parameters, type); - }, factoryDeprecation); - - /** @deprecated Use `factory.updateMethodSignature` or the factory supplied by your transformation context instead. */ - export const updateMethodSignature = Debug.deprecate(function updateMethodSignature( - node: MethodSignature, - typeParameters: NodeArray | undefined, - parameters: NodeArray, - type: TypeNode | undefined, - name: PropertyName, - questionToken: QuestionToken | undefined - ) { - return factory.updateMethodSignature(node, node.modifiers, name, questionToken, typeParameters, parameters, type); - }, factoryDeprecation); - - /** @deprecated Use `factory.createTypeOperatorNode` or the factory supplied by your transformation context instead. */ - export const createTypeOperatorNode = Debug.deprecate(function createTypeOperatorNode(operatorOrType: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword | TypeNode, type?: TypeNode) { - let operator: TypeOperatorNode["operator"]; - if (type) { - operator = operatorOrType as TypeOperatorNode["operator"]; - } - else { - type = operatorOrType as TypeNode; - operator = SyntaxKind.KeyOfKeyword; - } - return factory.createTypeOperatorNode(operator, type); - } as { - (type: TypeNode): TypeOperatorNode; - (operator: SyntaxKind.KeyOfKeyword | SyntaxKind.UniqueKeyword | SyntaxKind.ReadonlyKeyword, type: TypeNode): TypeOperatorNode; - }, factoryDeprecation); - - /** @deprecated Use `factory.createTaggedTemplate` or the factory supplied by your transformation context instead. */ - export const createTaggedTemplate = Debug.deprecate(function createTaggedTemplate(tag: Expression, typeArgumentsOrTemplate: readonly TypeNode[] | TemplateLiteral | undefined, template?: TemplateLiteral) { - let typeArguments: readonly TypeNode[] | undefined; - if (template) { - typeArguments = typeArgumentsOrTemplate as readonly TypeNode[] | undefined; - } - else { - template = typeArgumentsOrTemplate as TemplateLiteral; - } - return factory.createTaggedTemplateExpression(tag, typeArguments, template); - } as { - (tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - (tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; - }, factoryDeprecation); - - /** @deprecated Use `factory.updateTaggedTemplate` or the factory supplied by your transformation context instead. */ - export const updateTaggedTemplate = Debug.deprecate(function updateTaggedTemplate(node: TaggedTemplateExpression, tag: Expression, typeArgumentsOrTemplate: readonly TypeNode[] | TemplateLiteral | undefined, template?: TemplateLiteral) { - let typeArguments: readonly TypeNode[] | undefined; - if (template) { - typeArguments = typeArgumentsOrTemplate as readonly TypeNode[] | undefined; - } - else { - template = typeArgumentsOrTemplate as TemplateLiteral; - } - return factory.updateTaggedTemplateExpression(node, tag, typeArguments, template); - } as { - (node: TaggedTemplateExpression, tag: Expression, template: TemplateLiteral): TaggedTemplateExpression; - (node: TaggedTemplateExpression, tag: Expression, typeArguments: readonly TypeNode[] | undefined, template: TemplateLiteral): TaggedTemplateExpression; - }, factoryDeprecation); - - /** @deprecated Use `factory.updateBinary` or the factory supplied by your transformation context instead. */ - export const updateBinary = Debug.deprecate(function updateBinary(node: BinaryExpression, left: Expression, right: Expression, operator: BinaryOperator | BinaryOperatorToken = node.operatorToken) { - if (typeof operator === "number") { - operator = operator === node.operatorToken.kind ? node.operatorToken : factory.createToken(operator); - } - return factory.updateBinaryExpression(node, left, operator, right); - }, factoryDeprecation); - - /** @deprecated Use `factory.createConditional` or the factory supplied by your transformation context instead. */ - export const createConditional = Debug.deprecate(function createConditional(condition: Expression, questionTokenOrWhenTrue: QuestionToken | Expression, whenTrueOrWhenFalse: Expression, colonToken?: ColonToken, whenFalse?: Expression) { - return arguments.length === 5 ? factory.createConditionalExpression(condition, questionTokenOrWhenTrue as QuestionToken, whenTrueOrWhenFalse, colonToken, whenFalse!) : - arguments.length === 3 ? factory.createConditionalExpression(condition, factory.createToken(SyntaxKind.QuestionToken), questionTokenOrWhenTrue as Expression, factory.createToken(SyntaxKind.ColonToken), whenTrueOrWhenFalse) : - Debug.fail("Argument count mismatch"); - } as { - (condition: Expression, whenTrue: Expression, whenFalse: Expression): ConditionalExpression; - (condition: Expression, questionToken: QuestionToken, whenTrue: Expression, colonToken: ColonToken, whenFalse: Expression): ConditionalExpression; - }, factoryDeprecation); - - /** @deprecated Use `factory.createYield` or the factory supplied by your transformation context instead. */ - export const createYield = Debug.deprecate(function createYield(asteriskTokenOrExpression?: AsteriskToken | Expression | undefined, expression?: Expression) { - let asteriskToken: AsteriskToken | undefined; - if (expression) { - asteriskToken = asteriskTokenOrExpression as AsteriskToken; - } - else { - expression = asteriskTokenOrExpression as Expression; - } - return factory.createYieldExpression(asteriskToken, expression); - } as { - (expression?: Expression | undefined): YieldExpression; - (asteriskToken: AsteriskToken | undefined, expression: Expression): YieldExpression; - }, factoryDeprecation); - - /** @deprecated Use `factory.createClassExpression` or the factory supplied by your transformation context instead. */ - export const createClassExpression = Debug.deprecate(function createClassExpression( - modifiers: readonly Modifier[] | undefined, - name: string | Identifier | undefined, - typeParameters: readonly TypeParameterDeclaration[] | undefined, - heritageClauses: readonly HeritageClause[] | undefined, - members: readonly ClassElement[] - ) { - return factory.createClassExpression(/*decorators*/ undefined, modifiers, name, typeParameters, heritageClauses, members); - }, factoryDeprecation); - - /** @deprecated Use `factory.updateClassExpression` or the factory supplied by your transformation context instead. */ - export const updateClassExpression = Debug.deprecate(function updateClassExpression( - node: ClassExpression, - modifiers: readonly Modifier[] | undefined, - name: Identifier | undefined, - typeParameters: readonly TypeParameterDeclaration[] | undefined, - heritageClauses: readonly HeritageClause[] | undefined, - members: readonly ClassElement[] - ) { - return factory.updateClassExpression(node, /*decorators*/ undefined, modifiers, name, typeParameters, heritageClauses, members); - }, factoryDeprecation); - - /** @deprecated Use `factory.createPropertySignature` or the factory supplied by your transformation context instead. */ - export const createPropertySignature = Debug.deprecate(function createPropertySignature( - modifiers: readonly Modifier[] | undefined, - name: PropertyName | string, - questionToken: QuestionToken | undefined, - type: TypeNode | undefined, - initializer?: Expression | undefined - ): PropertySignature { - const node = factory.createPropertySignature(modifiers, name, questionToken, type); - node.initializer = initializer; - return node; - }, factoryDeprecation); - - /** @deprecated Use `factory.updatePropertySignature` or the factory supplied by your transformation context instead. */ - export const updatePropertySignature = Debug.deprecate(function updatePropertySignature( - node: PropertySignature, - modifiers: readonly Modifier[] | undefined, - name: PropertyName, - questionToken: QuestionToken | undefined, - type: TypeNode | undefined, - initializer: Expression | undefined - ) { - let updated = factory.updatePropertySignature(node, modifiers, name, questionToken, type); - if (node.initializer !== initializer) { - if (updated === node) { - updated = factory.cloneNode(node); - } - updated.initializer = initializer; - } - return updated; - }, factoryDeprecation); - - /** @deprecated Use `factory.createExpressionWithTypeArguments` or the factory supplied by your transformation context instead. */ - export const createExpressionWithTypeArguments = Debug.deprecate(function createExpressionWithTypeArguments(typeArguments: readonly TypeNode[] | undefined, expression: Expression) { - return factory.createExpressionWithTypeArguments(expression, typeArguments); - }, factoryDeprecation); - - /** @deprecated Use `factory.updateExpressionWithTypeArguments` or the factory supplied by your transformation context instead. */ - export const updateExpressionWithTypeArguments = Debug.deprecate(function updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, typeArguments: readonly TypeNode[] | undefined, expression: Expression) { - return factory.updateExpressionWithTypeArguments(node, expression, typeArguments); - }, factoryDeprecation); - - /** @deprecated Use `factory.createArrowFunction` or the factory supplied by your transformation context instead. */ - export const createArrowFunction = Debug.deprecate(function createArrowFunction(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanTokenOrBody: ConciseBody | EqualsGreaterThanToken | undefined, body?: ConciseBody) { - return arguments.length === 6 ? factory.createArrowFunction(modifiers, typeParameters, parameters, type, equalsGreaterThanTokenOrBody as EqualsGreaterThanToken | undefined, body!) : - arguments.length === 5 ? factory.createArrowFunction(modifiers, typeParameters, parameters, type, /*equalsGreaterThanToken*/ undefined, equalsGreaterThanTokenOrBody as ConciseBody) : - Debug.fail("Argument count mismatch"); - } as { - (modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken | undefined, body: ConciseBody): ArrowFunction; - (modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: ConciseBody): ArrowFunction; - }, factoryDeprecation); - - /** @deprecated Use `factory.updateArrowFunction` or the factory supplied by your transformation context instead. */ - export const updateArrowFunction = Debug.deprecate(function updateArrowFunction(node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanTokenOrBody: EqualsGreaterThanToken | ConciseBody, body?: ConciseBody) { - return arguments.length === 7 ? factory.updateArrowFunction(node, modifiers, typeParameters, parameters, type, equalsGreaterThanTokenOrBody as EqualsGreaterThanToken, body!) : - arguments.length === 6 ? factory.updateArrowFunction(node, modifiers, typeParameters, parameters, type, node.equalsGreaterThanToken, equalsGreaterThanTokenOrBody as ConciseBody) : - Debug.fail("Argument count mismatch"); - } as { - (node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, equalsGreaterThanToken: EqualsGreaterThanToken, body: ConciseBody): ArrowFunction; - (node: ArrowFunction, modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: ConciseBody): ArrowFunction; - }, factoryDeprecation); - - /** @deprecated Use `factory.createVariableDeclaration` or the factory supplied by your transformation context instead. */ - export const createVariableDeclaration = Debug.deprecate(function createVariableDeclaration(name: string | BindingName, exclamationTokenOrType?: ExclamationToken | TypeNode, typeOrInitializer?: TypeNode | Expression, initializer?: Expression) { - return arguments.length === 4 ? factory.createVariableDeclaration(name, exclamationTokenOrType as ExclamationToken | undefined, typeOrInitializer as TypeNode | undefined, initializer) : - arguments.length >= 1 && arguments.length <= 3 ? factory.createVariableDeclaration(name, /*exclamationToken*/ undefined, exclamationTokenOrType as TypeNode | undefined, typeOrInitializer as Expression | undefined) : - Debug.fail("Argument count mismatch"); - } as { - (name: string | BindingName, type?: TypeNode | undefined, initializer?: Expression | undefined): VariableDeclaration; - (name: string | BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - }, factoryDeprecation); - - /** @deprecated Use `factory.updateVariableDeclaration` or the factory supplied by your transformation context instead. */ - export const updateVariableDeclaration = Debug.deprecate(function updateVariableDeclaration(node: VariableDeclaration, name: BindingName, exclamationTokenOrType: ExclamationToken | TypeNode | undefined, typeOrInitializer: TypeNode | Expression | undefined, initializer?: Expression | undefined) { - return arguments.length === 5 ? factory.updateVariableDeclaration(node, name, exclamationTokenOrType as ExclamationToken | undefined, typeOrInitializer as TypeNode | undefined, initializer) : - arguments.length === 4 ? factory.updateVariableDeclaration(node, name, node.exclamationToken, exclamationTokenOrType as TypeNode | undefined, typeOrInitializer as Expression | undefined) : - Debug.fail("Argument count mismatch"); - } as { - (node: VariableDeclaration, name: BindingName, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - (node: VariableDeclaration, name: BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; - }, factoryDeprecation); - - /** @deprecated Use `factory.createImportClause` or the factory supplied by your transformation context instead. */ - export const createImportClause = Debug.deprecate(function createImportClause(name: Identifier | undefined, namedBindings: NamedImportBindings | undefined, isTypeOnly = false): ImportClause { - return factory.createImportClause(isTypeOnly, name, namedBindings); - }, factoryDeprecation); - - /** @deprecated Use `factory.updateImportClause` or the factory supplied by your transformation context instead. */ - export const updateImportClause = Debug.deprecate(function updateImportClause(node: ImportClause, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined, isTypeOnly: boolean) { - return factory.updateImportClause(node, isTypeOnly, name, namedBindings); - }, factoryDeprecation); - - /** @deprecated Use `factory.createExportDeclaration` or the factory supplied by your transformation context instead. */ - export const createExportDeclaration = Debug.deprecate(function createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression | undefined, isTypeOnly = false) { - return factory.createExportDeclaration(decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier); - }, factoryDeprecation); - - /** @deprecated Use `factory.updateExportDeclaration` or the factory supplied by your transformation context instead. */ - export const updateExportDeclaration = Debug.deprecate(function updateExportDeclaration( - node: ExportDeclaration, - decorators: readonly Decorator[] | undefined, - modifiers: readonly Modifier[] | undefined, - exportClause: NamedExportBindings | undefined, - moduleSpecifier: Expression | undefined, - isTypeOnly: boolean) { - return factory.updateExportDeclaration(node, decorators, modifiers, isTypeOnly, exportClause, moduleSpecifier, node.assertClause); - }, factoryDeprecation); - - /** @deprecated Use `factory.createJSDocParameterTag` or the factory supplied by your transformation context instead. */ - export const createJSDocParamTag = Debug.deprecate(function createJSDocParamTag(name: EntityName, isBracketed: boolean, typeExpression?: JSDocTypeExpression | undefined, comment?: string | undefined): JSDocParameterTag { - return factory.createJSDocParameterTag(/*tagName*/ undefined, name, isBracketed, typeExpression, /*isNameFirst*/ false, comment ? factory.createNodeArray([factory.createJSDocText(comment)]) : undefined); - }, factoryDeprecation); - - /** @deprecated Use `factory.createComma` or the factory supplied by your transformation context instead. */ - export const createComma = Debug.deprecate(function createComma(left: Expression, right: Expression): Expression { - return factory.createComma(left, right); - }, factoryDeprecation); - - /** @deprecated Use `factory.createLessThan` or the factory supplied by your transformation context instead. */ - export const createLessThan = Debug.deprecate(function createLessThan(left: Expression, right: Expression): Expression { - return factory.createLessThan(left, right); - }, factoryDeprecation); - - /** @deprecated Use `factory.createAssignment` or the factory supplied by your transformation context instead. */ - export const createAssignment = Debug.deprecate(function createAssignment(left: Expression, right: Expression): BinaryExpression { - return factory.createAssignment(left, right); - }, factoryDeprecation); - - /** @deprecated Use `factory.createStrictEquality` or the factory supplied by your transformation context instead. */ - export const createStrictEquality = Debug.deprecate(function createStrictEquality(left: Expression, right: Expression): BinaryExpression { - return factory.createStrictEquality(left, right); - }, factoryDeprecation); - - /** @deprecated Use `factory.createStrictInequality` or the factory supplied by your transformation context instead. */ - export const createStrictInequality = Debug.deprecate(function createStrictInequality(left: Expression, right: Expression): BinaryExpression { - return factory.createStrictInequality(left, right); - }, factoryDeprecation); - - /** @deprecated Use `factory.createAdd` or the factory supplied by your transformation context instead. */ - export const createAdd = Debug.deprecate(function createAdd(left: Expression, right: Expression): BinaryExpression { - return factory.createAdd(left, right); - }, factoryDeprecation); - - /** @deprecated Use `factory.createSubtract` or the factory supplied by your transformation context instead. */ - export const createSubtract = Debug.deprecate(function createSubtract(left: Expression, right: Expression): BinaryExpression { - return factory.createSubtract(left, right); - }, factoryDeprecation); - - /** @deprecated Use `factory.createLogicalAnd` or the factory supplied by your transformation context instead. */ - export const createLogicalAnd = Debug.deprecate(function createLogicalAnd(left: Expression, right: Expression): BinaryExpression { - return factory.createLogicalAnd(left, right); - }, factoryDeprecation); - - /** @deprecated Use `factory.createLogicalOr` or the factory supplied by your transformation context instead. */ - export const createLogicalOr = Debug.deprecate(function createLogicalOr(left: Expression, right: Expression): BinaryExpression { - return factory.createLogicalOr(left, right); - }, factoryDeprecation); - - /** @deprecated Use `factory.createPostfixIncrement` or the factory supplied by your transformation context instead. */ - export const createPostfixIncrement = Debug.deprecate(function createPostfixIncrement(operand: Expression): PostfixUnaryExpression { - return factory.createPostfixIncrement(operand); - }, factoryDeprecation); - - /** @deprecated Use `factory.createLogicalNot` or the factory supplied by your transformation context instead. */ - export const createLogicalNot = Debug.deprecate(function createLogicalNot(operand: Expression): PrefixUnaryExpression { - return factory.createLogicalNot(operand); - }, factoryDeprecation); - - /** @deprecated Use an appropriate `factory` method instead. */ - export const createNode = Debug.deprecate(function createNode(kind: SyntaxKind, pos = 0, end = 0): Node { - return setTextRangePosEnd( - kind === SyntaxKind.SourceFile ? parseBaseNodeFactory.createBaseSourceFileNode(kind) : - kind === SyntaxKind.Identifier ? parseBaseNodeFactory.createBaseIdentifierNode(kind) : - kind === SyntaxKind.PrivateIdentifier ? parseBaseNodeFactory.createBasePrivateIdentifierNode(kind) : - !isNodeKind(kind) ? parseBaseNodeFactory.createBaseTokenNode(kind) : - parseBaseNodeFactory.createBaseNode(kind), - pos, - end - ); - }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory` method instead." }); - - /** - * Creates a shallow, memberwise clone of a node ~for mutation~ with its `pos`, `end`, and `parent` set. - * - * NOTE: It is unsafe to change any properties of a `Node` that relate to its AST children, as those changes won't be - * captured with respect to transformations. - * - * @deprecated Use an appropriate `factory.update...` method instead, use `setCommentRange` or `setSourceMapRange`, and avoid setting `parent`. - */ - export const getMutableClone = Debug.deprecate(function getMutableClone(node: T): T { - const clone = factory.cloneNode(node); - setTextRange(clone, node); - setParent(clone, node.parent); - return clone; - }, { since: "4.0", warnAfter: "4.1", message: "Use an appropriate `factory.update...` method instead, use `setCommentRange` or `setSourceMapRange`, and avoid setting `parent`." }); - - // #endregion Node Factory top-level exports - - // DEPRECATION: Renamed node tests - // DEPRECATION PLAN: - // - soft: 4.0 - // - warn: 4.1 - // - error: TBD - // #region Renamed node Tests - - /** @deprecated Use `isTypeAssertionExpression` instead. */ - export const isTypeAssertion = Debug.deprecate(function isTypeAssertion(node: Node): node is TypeAssertion { - return node.kind === SyntaxKind.TypeAssertionExpression; - }, { - since: "4.0", - warnAfter: "4.1", - message: "Use `isTypeAssertionExpression` instead." - }); - - // #endregion Renamed node Tests - - // DEPRECATION: Renamed `Map` and `ReadonlyMap` interfaces - // DEPRECATION PLAN: - // - soft: 4.0 - // - remove: TBD (will remove for at least one release before replacing with `ESMap`/`ReadonlyESMap`) - // - replace: TBD (will eventually replace with `ESMap`/`ReadonlyESMap`) - // #region Renamed `Map` and `ReadonlyMap` interfaces - - /** - * @deprecated Use `ts.ReadonlyESMap` instead. - */ - export interface ReadonlyMap extends ReadonlyESMap { - } - - /** - * @deprecated Use `ts.ESMap` instead. - */ - export interface Map extends ESMap { } - - // #endregion - - // DEPRECATION: Renamed node tests - // DEPRECATION PLAN: - // - soft: 4.2 - // - warn: 4.3 - // - error: TBD - // #region Renamed node Tests - - /** - * @deprecated Use `isMemberName` instead. - */ - export const isIdentifierOrPrivateIdentifier = Debug.deprecate(function isIdentifierOrPrivateIdentifier(node: Node): node is MemberName { - return isMemberName(node); - }, { - since: "4.2", - warnAfter: "4.3", - message: "Use `isMemberName` instead." - }); - - // #endregion Renamed node Tests -} +// The following are deprecations for the public API. Deprecated exports are removed from the compiler itself +// and compatible implementations are added here, along with an appropriate deprecation warning using +// the `@deprecated` JSDoc tag as well as the `Debug.deprecate` API. +// +// Deprecations fall into one of three categories: +// +// - "soft" - Soft deprecations are indicated with the `@deprecated` JSDoc Tag. +// - "warn" - Warning deprecations are indicated with the `@deprecated` JSDoc Tag and a diagnostic message (assuming a compatible host). +// - "error" - Error deprecations are either indicated with the `@deprecated` JSDoc tag and will throw a `TypeError` when invoked, or removed from the API entirely. +// +// Once we have determined enough time has passed after a deprecation has been marked as `"warn"` or `"error"`, it will be removed from the public API. \ No newline at end of file diff --git a/src/deprecatedCompat/tsconfig.json b/src/deprecatedCompat/tsconfig.json index 5217469c26c5f..6759eef3bb1a5 100644 --- a/src/deprecatedCompat/tsconfig.json +++ b/src/deprecatedCompat/tsconfig.json @@ -7,6 +7,14 @@ { "path": "../compiler" } ], "files": [ - "deprecations.ts" + "deprecations.ts", + "4.0/nodeFactoryTopLevelExports.ts", + "4.0/renamedNodeTests.ts", + "4.0/renamedMapInterfaces.ts", + "4.2/renamedNodeTests.ts", + "4.2/abstractConstructorTypes.ts", + "4.6/importTypeAssertions.ts", + "4.7/typeParameterModifiers.ts", + "4.8/mergeDecoratorsAndModifiers.ts" ] } \ No newline at end of file diff --git a/src/harness/tsconfig.json b/src/harness/tsconfig.json index 37c2452773098..533ac9c4d3952 100644 --- a/src/harness/tsconfig.json +++ b/src/harness/tsconfig.json @@ -15,7 +15,8 @@ { "path": "../services" }, { "path": "../jsTyping" }, { "path": "../server" }, - { "path": "../typingsInstallerCore" } + { "path": "../typingsInstallerCore" }, + { "path": "../deprecatedCompat" }, ], "files": [ diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index a1ac3630f319f..4d398526b7bda 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -35,8 +35,9 @@ namespace ts.BreakpointResolver { return spanInNode(tokenAtLocation); function textSpan(startNode: Node, endNode?: Node) { - const start = startNode.decorators ? - skipTrivia(sourceFile.text, startNode.decorators.end) : + const lastDecorator = canHaveDecorators(startNode) ? findLast(startNode.modifiers, isDecorator) : undefined; + const start = lastDecorator ? + skipTrivia(sourceFile.text, lastDecorator.end) : startNode.getStart(sourceFile); return createTextSpanFromBounds(start, (endNode || startNode).getEnd()); } @@ -52,8 +53,18 @@ namespace ts.BreakpointResolver { return spanInNode(otherwiseOnNode); } - function spanInNodeArray(nodeArray: NodeArray) { - return createTextSpanFromBounds(skipTrivia(sourceFile.text, nodeArray.pos), nodeArray.end); + function spanInNodeArray(nodeArray: NodeArray | undefined, node: T, match: (value: Node) => boolean) { + if (nodeArray) { + const index = nodeArray.indexOf(node); + if (index >= 0) { + let start = index; + let end = index + 1; + while (start > 0 && match(nodeArray[start - 1])) start--; + while (end < nodeArray.length && match(nodeArray[end])) end++; + return createTextSpanFromBounds(skipTrivia(sourceFile.text, nodeArray[start].pos), nodeArray[end - 1].end); + } + } + return textSpan(node); } function spanInPreviousNode(node: Node): TextSpan | undefined { @@ -197,7 +208,7 @@ namespace ts.BreakpointResolver { return spanInNode((node as WithStatement).statement); case SyntaxKind.Decorator: - return spanInNodeArray(parent.decorators!); + return spanInNodeArray((parent as HasDecorators).modifiers, node, isDecorator); case SyntaxKind.ObjectBindingPattern: case SyntaxKind.ArrayBindingPattern: @@ -391,7 +402,7 @@ namespace ts.BreakpointResolver { // Breakpoint is possible in variableDeclaration only if there is initialization // or its declaration from 'for of' - if (variableDeclaration.initializer || + if ((hasOnlyExpressionInitializer(variableDeclaration) && variableDeclaration.initializer) || hasSyntacticModifier(variableDeclaration, ModifierFlags.Export) || parent.parent.kind === SyntaxKind.ForOfStatement) { return textSpanFromVariableDeclaration(variableDeclaration); diff --git a/src/services/callHierarchy.ts b/src/services/callHierarchy.ts index bfb533b0160b2..1cbe4e58ada82 100644 --- a/src/services/callHierarchy.ts +++ b/src/services/callHierarchy.ts @@ -77,7 +77,7 @@ namespace ts.CallHierarchy { } /** Gets the node that can be used as a reference to a call hierarchy declaration. */ - function getCallHierarchyDeclarationReferenceNode(node: CallHierarchyDeclaration) { + function getCallHierarchyDeclarationReferenceNode(node: Exclude) { if (isSourceFile(node)) return node; if (isNamedDeclaration(node)) return node.name; if (isConstNamedExpression(node)) return node.parent.name; @@ -89,7 +89,7 @@ namespace ts.CallHierarchy { } /** Gets the symbol for a call hierarchy declaration. */ - function getSymbolOfCallHierarchyDeclaration(typeChecker: TypeChecker, node: CallHierarchyDeclaration) { + function getSymbolOfCallHierarchyDeclaration(typeChecker: TypeChecker, node: Exclude) { const location = getCallHierarchyDeclarationReferenceNode(node); return location && typeChecker.getSymbolAtLocation(location); } @@ -187,7 +187,7 @@ namespace ts.CallHierarchy { return node; } - function findAllInitialDeclarations(typeChecker: TypeChecker, node: CallHierarchyDeclaration) { + function findAllInitialDeclarations(typeChecker: TypeChecker, node: Exclude) { const symbol = getSymbolOfCallHierarchyDeclaration(typeChecker, node); let declarations: CallHierarchyDeclaration[] | undefined; if (symbol && symbol.declarations) { @@ -484,13 +484,15 @@ namespace ts.CallHierarchy { } function collectCallSitesOfClassLikeDeclaration(node: ClassLikeDeclaration, collect: (node: Node | undefined) => void) { - forEach(node.decorators, collect); + forEach(node.modifiers, collect); const heritage = getClassExtendsHeritageElement(node); if (heritage) { collect(heritage.expression); } for (const member of node.members) { - forEach(member.decorators, collect); + if (canHaveModifiers(member)) { + forEach(member.modifiers, collect); + } if (isPropertyDeclaration(member)) { collect(member.initializer); } diff --git a/src/services/codefixes/addEmptyExportDeclaration.ts b/src/services/codefixes/addEmptyExportDeclaration.ts index de0dee3acbc63..478fcb83040b3 100644 --- a/src/services/codefixes/addEmptyExportDeclaration.ts +++ b/src/services/codefixes/addEmptyExportDeclaration.ts @@ -9,7 +9,7 @@ namespace ts.codefix { const { sourceFile } = context; const changes = textChanges.ChangeTracker.with(context, changes => { const exportDeclaration = factory.createExportDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([]), diff --git a/src/services/codefixes/addNameToNamelessParameter.ts b/src/services/codefixes/addNameToNamelessParameter.ts index d9aec73ee966e..878cb30d89964 100644 --- a/src/services/codefixes/addNameToNamelessParameter.ts +++ b/src/services/codefixes/addNameToNamelessParameter.ts @@ -25,7 +25,7 @@ namespace ts.codefix { const typeNode = factory.createTypeReferenceNode(param.name as Identifier, /*typeArguments*/ undefined); const replacement = factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, param.modifiers, param.dotDotDotToken, "arg" + i, diff --git a/src/services/codefixes/annotateWithTypeFromJSDoc.ts b/src/services/codefixes/annotateWithTypeFromJSDoc.ts index 274902c1041bb..ce0a839fda655 100644 --- a/src/services/codefixes/annotateWithTypeFromJSDoc.ts +++ b/src/services/codefixes/annotateWithTypeFromJSDoc.ts @@ -120,7 +120,7 @@ namespace ts.codefix { const isRest = node.type!.kind === SyntaxKind.JSDocVariadicType && index === node.parent.parameters.length - 1; // TODO: GH#18217 const name = node.name || (isRest ? "rest" : "arg" + index); const dotdotdot = isRest ? factory.createToken(SyntaxKind.DotDotDotToken) : node.dotDotDotToken; - return factory.createParameterDeclaration(node.decorators, node.modifiers, dotdotdot, name, node.questionToken, visitNode(node.type, transformJSDocType), node.initializer); + return factory.createParameterDeclaration(RESERVED, node.modifiers, dotdotdot, name, node.questionToken, visitNode(node.type, transformJSDocType), node.initializer); } function transformJSDocTypeReference(node: TypeReferenceNode) { @@ -157,14 +157,14 @@ namespace ts.codefix { function transformJSDocIndexSignature(node: TypeReferenceNode) { const index = factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, node.typeArguments![0].kind === SyntaxKind.NumberKeyword ? "n" : "s", /*questionToken*/ undefined, factory.createTypeReferenceNode(node.typeArguments![0].kind === SyntaxKind.NumberKeyword ? "number" : "string", []), /*initializer*/ undefined); - const indexSignature = factory.createTypeLiteralNode([factory.createIndexSignature(/*decorators*/ undefined, /*modifiers*/ undefined, [index], node.typeArguments![1])]); + const indexSignature = factory.createTypeLiteralNode([factory.createIndexSignature(RESERVED, /*modifiers*/ undefined, [index], node.typeArguments![1])]); setEmitFlags(indexSignature, EmitFlags.SingleLine); return indexSignature; } diff --git a/src/services/codefixes/convertFunctionToEs6Class.ts b/src/services/codefixes/convertFunctionToEs6Class.ts index 352fbbb5bc160..c30c61c6ac803 100644 --- a/src/services/codefixes/convertFunctionToEs6Class.ts +++ b/src/services/codefixes/convertFunctionToEs6Class.ts @@ -137,7 +137,7 @@ namespace ts.codefix { changes.delete(sourceFile, nodeToDelete); if (!assignmentExpr) { - members.push(factory.createPropertyDeclaration([], modifiers, symbol.name, /*questionToken*/ undefined, + members.push(factory.createPropertyDeclaration(RESERVED, modifiers, symbol.name, /*questionToken*/ undefined, /*type*/ undefined, /*initializer*/ undefined)); return; } @@ -174,7 +174,7 @@ namespace ts.codefix { // Don't try to declare members in JavaScript files if (isSourceFileJS(sourceFile)) return; if (!isPropertyAccessExpression(memberDeclaration)) return; - const prop = factory.createPropertyDeclaration(/*decorators*/ undefined, modifiers, memberDeclaration.name, /*questionToken*/ undefined, /*type*/ undefined, assignmentExpr); + const prop = factory.createPropertyDeclaration(RESERVED, modifiers, memberDeclaration.name, /*questionToken*/ undefined, /*type*/ undefined, assignmentExpr); copyLeadingComments(assignmentBinaryExpression.parent, prop, sourceFile); members.push(prop); return; @@ -187,7 +187,7 @@ namespace ts.codefix { function createFunctionExpressionMember(members: ClassElement[], functionExpression: FunctionExpression, name: PropertyName) { const fullModifiers = concatenate(modifiers, getModifierKindFromSource(functionExpression, SyntaxKind.AsyncKeyword)); - const method = factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, + const method = factory.createMethodDeclaration(RESERVED, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, functionExpression.parameters, /*type*/ undefined, functionExpression.body); copyLeadingComments(assignmentBinaryExpression, method, sourceFile); members.push(method); @@ -207,7 +207,7 @@ namespace ts.codefix { bodyBlock = factory.createBlock([factory.createReturnStatement(arrowFunctionBody)]); } const fullModifiers = concatenate(modifiers, getModifierKindFromSource(arrowFunction, SyntaxKind.AsyncKeyword)); - const method = factory.createMethodDeclaration(/*decorators*/ undefined, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, + const method = factory.createMethodDeclaration(RESERVED, fullModifiers, /*asteriskToken*/ undefined, name, /*questionToken*/ undefined, /*typeParameters*/ undefined, arrowFunction.parameters, /*type*/ undefined, bodyBlock); copyLeadingComments(assignmentBinaryExpression, method, sourceFile); members.push(method); @@ -223,11 +223,11 @@ namespace ts.codefix { const memberElements = createClassElementsFromSymbol(node.symbol); if (initializer.body) { - memberElements.unshift(factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, initializer.parameters, initializer.body)); + memberElements.unshift(factory.createConstructorDeclaration(RESERVED, /*modifiers*/ undefined, initializer.parameters, initializer.body)); } const modifiers = getModifierKindFromSource(node.parent.parent, SyntaxKind.ExportKeyword); - const cls = factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, + const cls = factory.createClassDeclaration(RESERVED, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place return cls; @@ -236,19 +236,19 @@ namespace ts.codefix { function createClassFromFunctionDeclaration(node: FunctionDeclaration): ClassDeclaration { const memberElements = createClassElementsFromSymbol(ctorSymbol); if (node.body) { - memberElements.unshift(factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, node.parameters, node.body)); + memberElements.unshift(factory.createConstructorDeclaration(RESERVED, /*modifiers*/ undefined, node.parameters, node.body)); } const modifiers = getModifierKindFromSource(node, SyntaxKind.ExportKeyword); - const cls = factory.createClassDeclaration(/*decorators*/ undefined, modifiers, node.name, + const cls = factory.createClassDeclaration(RESERVED, modifiers, node.name, /*typeParameters*/ undefined, /*heritageClauses*/ undefined, memberElements); // Don't call copyComments here because we'll already leave them in place return cls; } } - function getModifierKindFromSource(source: Node, kind: SyntaxKind): readonly Modifier[] | undefined { - return filter(source.modifiers, modifier => modifier.kind === kind); + function getModifierKindFromSource(source: Node, kind: Modifier["kind"]): readonly Modifier[] | undefined { + return canHaveModifiers(source) ? filter(source.modifiers, (modifier): modifier is Modifier => modifier.kind === kind) : undefined; } function isConstructorAssignment(x: ObjectLiteralElementLike | PropertyAccessExpression) { diff --git a/src/services/codefixes/convertToAsyncFunction.ts b/src/services/codefixes/convertToAsyncFunction.ts index 3c6045fdb6c78..a245f0aff4943 100644 --- a/src/services/codefixes/convertToAsyncFunction.ts +++ b/src/services/codefixes/convertToAsyncFunction.ts @@ -82,11 +82,10 @@ namespace ts.codefix { return; } - const pos = functionToConvert.modifiers ? functionToConvert.modifiers.end : - functionToConvert.decorators ? skipTrivia(sourceFile.text, functionToConvert.decorators.end) : - functionToConvert.getStart(sourceFile); - const options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; - changes.insertModifierAt(sourceFile, pos, SyntaxKind.AsyncKeyword, options); + const pos = skipTrivia(sourceFile.text, moveRangePastModifiers(functionToConvert).pos); + // const pos = functionToConvert.modifiers?.end ?? functionToConvert.getStart(sourceFile); + // const options = functionToConvert.modifiers ? { prefix: " " } : { suffix: " " }; + changes.insertModifierAt(sourceFile, pos, SyntaxKind.AsyncKeyword, { suffix: " " }); for (const returnStatement of returnStatements) { forEachChild(returnStatement, function visit(node) { diff --git a/src/services/codefixes/convertToEsModule.ts b/src/services/codefixes/convertToEsModule.ts index 57c4e7995b6b2..00f944055e8bd 100644 --- a/src/services/codefixes/convertToEsModule.ts +++ b/src/services/codefixes/convertToEsModule.ts @@ -544,7 +544,7 @@ namespace ts.codefix { function functionExpressionToDeclaration(name: string | undefined, additionalModifiers: readonly Modifier[], fn: FunctionExpression | ArrowFunction | MethodDeclaration, useSitesToUnqualify: ESMap | undefined): FunctionDeclaration { return factory.createFunctionDeclaration( - getSynthesizedDeepClones(fn.decorators), // TODO: GH#19915 Don't think this is even legal. + RESERVED, concatenate(additionalModifiers, getSynthesizedDeepClones(fn.modifiers)), getSynthesizedDeepClone(fn.asteriskToken), name, @@ -556,7 +556,7 @@ namespace ts.codefix { function classExpressionToDeclaration(name: string | undefined, additionalModifiers: readonly Modifier[], cls: ClassExpression, useSitesToUnqualify: ESMap | undefined): ClassDeclaration { return factory.createClassDeclaration( - getSynthesizedDeepClones(cls.decorators), // TODO: GH#19915 Don't think this is even legal. + RESERVED, concatenate(additionalModifiers, getSynthesizedDeepClones(cls.modifiers)), name, getSynthesizedDeepClones(cls.typeParameters), @@ -584,7 +584,7 @@ namespace ts.codefix { function makeExportDeclaration(exportSpecifiers: ExportSpecifier[] | undefined, moduleSpecifier?: string): ExportDeclaration { return factory.createExportDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, exportSpecifiers && factory.createNamedExports(exportSpecifiers), diff --git a/src/services/codefixes/convertToMappedObjectType.ts b/src/services/codefixes/convertToMappedObjectType.ts index 13429f17ec974..03497805607b0 100644 --- a/src/services/codefixes/convertToMappedObjectType.ts +++ b/src/services/codefixes/convertToMappedObjectType.ts @@ -35,7 +35,7 @@ namespace ts.codefix { } function createTypeAliasFromInterface(declaration: FixableDeclaration, type: TypeNode): TypeAliasDeclaration { - return factory.createTypeAliasDeclaration(declaration.decorators, declaration.modifiers, declaration.name, declaration.typeParameters, type); + return factory.createTypeAliasDeclaration(RESERVED, declaration.modifiers, declaration.name, declaration.typeParameters, type); } function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, { indexSignature, container }: Info): void { diff --git a/src/services/codefixes/convertToTypeOnlyExport.ts b/src/services/codefixes/convertToTypeOnlyExport.ts index 8cd4be7a20e60..18989a37463d3 100644 --- a/src/services/codefixes/convertToTypeOnlyExport.ts +++ b/src/services/codefixes/convertToTypeOnlyExport.ts @@ -40,7 +40,7 @@ namespace ts.codefix { else { const valueExportDeclaration = factory.updateExportDeclaration( exportDeclaration, - exportDeclaration.decorators, + RESERVED, exportDeclaration.modifiers, /*isTypeOnly*/ false, factory.updateNamedExports(exportClause, filter(exportClause.elements, e => !contains(typeExportSpecifiers, e))), @@ -48,7 +48,7 @@ namespace ts.codefix { /*assertClause*/ undefined ); const typeExportDeclaration = factory.createExportDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ true, factory.createNamedExports(typeExportSpecifiers), diff --git a/src/services/codefixes/convertToTypeOnlyImport.ts b/src/services/codefixes/convertToTypeOnlyImport.ts index 0f92c4108cfba..4dc8fc202d4b7 100644 --- a/src/services/codefixes/convertToTypeOnlyImport.ts +++ b/src/services/codefixes/convertToTypeOnlyImport.ts @@ -40,7 +40,7 @@ namespace ts.codefix { changes.deleteNodeRangeExcludingEnd(context.sourceFile, importClause.name, importDeclaration.importClause.namedBindings); changes.insertNodeBefore(context.sourceFile, importDeclaration, factory.updateImportDeclaration( importDeclaration, - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.createImportClause( /*isTypeOnly*/ true, diff --git a/src/services/codefixes/fixAddMissingMember.ts b/src/services/codefixes/fixAddMissingMember.ts index d7606830ea1ea..a798f6ffacdb9 100644 --- a/src/services/codefixes/fixAddMissingMember.ts +++ b/src/services/codefixes/fixAddMissingMember.ts @@ -278,7 +278,7 @@ namespace ts.codefix { } else if (isPrivateIdentifier(token)) { const property = factory.createPropertyDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, tokenName, /*questionToken*/ undefined, @@ -345,7 +345,7 @@ namespace ts.codefix { const modifiers = modifierFlags ? factory.createNodeArray(factory.createModifiersFromModifierFlags(modifierFlags)) : undefined; const property = isClassLike(node) - ? factory.createPropertyDeclaration(/*decorators*/ undefined, modifiers, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined) + ? factory.createPropertyDeclaration(RESERVED, modifiers, tokenName, /*questionToken*/ undefined, typeNode, /*initializer*/ undefined) : factory.createPropertySignature(/*modifiers*/ undefined, tokenName, /*questionToken*/ undefined, typeNode); const lastProp = getNodeToInsertPropertyAfter(node); @@ -371,7 +371,7 @@ namespace ts.codefix { // Index signatures cannot have the static modifier. const stringTypeNode = factory.createKeywordTypeNode(SyntaxKind.StringKeyword); const indexingParameter = factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, "x", @@ -379,7 +379,7 @@ namespace ts.codefix { stringTypeNode, /*initializer*/ undefined); const indexSignature = factory.createIndexSignature( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, [indexingParameter], typeNode); @@ -445,7 +445,7 @@ namespace ts.codefix { const enumMember = factory.createEnumMember(token, hasStringInitializer ? factory.createStringLiteral(token.text) : undefined); changes.replaceNode(parentDeclaration.getSourceFile(), parentDeclaration, factory.updateEnumDeclaration( parentDeclaration, - parentDeclaration.decorators, + RESERVED, parentDeclaration.modifiers, parentDeclaration.name, concatenate(parentDeclaration.members, singleElementArray(enumMember)) diff --git a/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts b/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts index cd647bc23578d..e4fcf98e5e81e 100644 --- a/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts +++ b/src/services/codefixes/fixAddModuleReferTypeMissingTypeof.ts @@ -25,7 +25,7 @@ namespace ts.codefix { } function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, importType: ImportTypeNode) { - const newTypeNode = factory.updateImportTypeNode(importType, importType.argument, importType.qualifier, importType.typeArguments, /* isTypeOf */ true); + const newTypeNode = factory.updateImportTypeNode(importType, importType.argument, importType.assertions, importType.qualifier, importType.typeArguments, /* isTypeOf */ true); changes.replaceNode(sourceFile, importType, newTypeNode); } } diff --git a/src/services/codefixes/fixInvalidImportSyntax.ts b/src/services/codefixes/fixInvalidImportSyntax.ts index c25d6efd62f48..1f19792690a4f 100644 --- a/src/services/codefixes/fixInvalidImportSyntax.ts +++ b/src/services/codefixes/fixInvalidImportSyntax.ts @@ -14,7 +14,7 @@ namespace ts.codefix { if (getEmitModuleKind(opts) === ModuleKind.CommonJS) { // import Bluebird = require("bluebird"); variations.push(createAction(context, sourceFile, node, factory.createImportEqualsDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, namespace.name, diff --git a/src/services/codefixes/fixOverrideModifier.ts b/src/services/codefixes/fixOverrideModifier.ts index 1eb9531130d3e..008a9b44ae0d5 100644 --- a/src/services/codefixes/fixOverrideModifier.ts +++ b/src/services/codefixes/fixOverrideModifier.ts @@ -143,10 +143,11 @@ namespace ts.codefix { const staticModifier = find(modifiers, isStaticModifier); const abstractModifier = find(modifiers, isAbstractModifier); const accessibilityModifier = find(modifiers, m => isAccessibilityModifier(m.kind)); + const lastDecorator = findLast(modifiers, isDecorator); const modifierPos = abstractModifier ? abstractModifier.end : staticModifier ? staticModifier.end : accessibilityModifier ? accessibilityModifier.end : - classElement.decorators ? skipTrivia(sourceFile.text, classElement.decorators.end) : classElement.getStart(sourceFile); + lastDecorator ? skipTrivia(sourceFile.text, lastDecorator.end) : classElement.getStart(sourceFile); const options = accessibilityModifier || staticModifier || abstractModifier ? { prefix: " " } : { suffix: " " }; changeTracker.insertModifierAt(sourceFile, modifierPos, SyntaxKind.OverrideKeyword, options); } @@ -157,7 +158,7 @@ namespace ts.codefix { changeTracker.filterJSDocTags(sourceFile, classElement, not(isJSDocOverrideTag)); return; } - const overrideModifier = classElement.modifiers && find(classElement.modifiers, modifier => modifier.kind === SyntaxKind.OverrideKeyword); + const overrideModifier = find(classElement.modifiers, isOverrideModifier); Debug.assertIsDefined(overrideModifier); changeTracker.deleteModifier(sourceFile, overrideModifier); diff --git a/src/services/codefixes/fixStrictClassInitialization.ts b/src/services/codefixes/fixStrictClassInitialization.ts index 67f5e41f7d485..f7d9b55e6a42b 100644 --- a/src/services/codefixes/fixStrictClassInitialization.ts +++ b/src/services/codefixes/fixStrictClassInitialization.ts @@ -70,7 +70,7 @@ namespace ts.codefix { suppressLeadingAndTrailingTrivia(propertyDeclaration); const property = factory.updatePropertyDeclaration( propertyDeclaration, - propertyDeclaration.decorators, + RESERVED, propertyDeclaration.modifiers, propertyDeclaration.name, factory.createToken(SyntaxKind.ExclamationToken), @@ -112,7 +112,7 @@ namespace ts.codefix { suppressLeadingAndTrailingTrivia(propertyDeclaration); const property = factory.updatePropertyDeclaration( propertyDeclaration, - propertyDeclaration.decorators, + RESERVED, propertyDeclaration.modifiers, propertyDeclaration.name, propertyDeclaration.questionToken, diff --git a/src/services/codefixes/fixUnusedIdentifier.ts b/src/services/codefixes/fixUnusedIdentifier.ts index df44b8b2e5a3b..9ad0df5a8c51d 100644 --- a/src/services/codefixes/fixUnusedIdentifier.ts +++ b/src/services/codefixes/fixUnusedIdentifier.ts @@ -256,7 +256,11 @@ namespace ts.codefix { if (mayDeleteParameter(checker, sourceFile, parameter, sourceFiles, program, cancellationToken, isFixAll)) { if (parameter.modifiers && parameter.modifiers.length > 0 && (!isIdentifier(parameter.name) || FindAllReferences.Core.isSymbolReferencedInFile(parameter.name, checker, sourceFile))) { - parameter.modifiers.forEach(modifier => changes.deleteModifier(sourceFile, modifier)); + for (const modifier of parameter.modifiers) { + if (isModifier(modifier)) { + changes.deleteModifier(sourceFile, modifier); + } + } } else if (!parameter.initializer && isNotProvidedArguments(parameter, checker, sourceFiles)) { changes.delete(sourceFile, parameter); diff --git a/src/services/codefixes/generateAccessors.ts b/src/services/codefixes/generateAccessors.ts index 92ad1f62f7b70..fa7e1dd9852cc 100644 --- a/src/services/codefixes/generateAccessors.ts +++ b/src/services/codefixes/generateAccessors.ts @@ -29,8 +29,8 @@ namespace ts.codefix { suppressLeadingAndTrailingTrivia(declaration); suppressLeadingAndTrailingTrivia(container); - let accessorModifiers: ModifiersArray | undefined; - let fieldModifiers: ModifiersArray | undefined; + let accessorModifiers: NodeArray | undefined; + let fieldModifiers: readonly ModifierLike[] | undefined; if (isClassLike(container)) { const modifierFlags = getEffectiveModifierFlags(declaration); if (isSourceFileJS(file)) { @@ -42,6 +42,9 @@ namespace ts.codefix { accessorModifiers = createModifiers(prepareModifierFlagsForAccessor(modifierFlags)); fieldModifiers = createModifiers(prepareModifierFlagsForField(modifierFlags)); } + if (canHaveDecorators(declaration)) { + fieldModifiers = concatenate(getDecorators(declaration), fieldModifiers); + } } updateFieldDeclaration(changeTracker, file, declaration, type, fieldName, fieldModifiers); @@ -120,7 +123,7 @@ namespace ts.codefix { }; } - if ((getEffectiveModifierFlags(declaration) | meaning) !== meaning) { + if (((getEffectiveModifierFlags(declaration) & ModifierFlags.Modifier) | meaning) !== meaning) { return { error: getLocaleSpecificMessage(Diagnostics.Can_only_convert_property_with_modifier) }; @@ -143,9 +146,9 @@ namespace ts.codefix { }; } - function generateGetAccessor(fieldName: AcceptedNameType, accessorName: AcceptedNameType, type: TypeNode | undefined, modifiers: ModifiersArray | undefined, isStatic: boolean, container: ContainerDeclaration) { + function generateGetAccessor(fieldName: AcceptedNameType, accessorName: AcceptedNameType, type: TypeNode | undefined, modifiers: NodeArray | undefined, isStatic: boolean, container: ContainerDeclaration) { return factory.createGetAccessorDeclaration( - /*decorators*/ undefined, + RESERVED, modifiers, accessorName, /*parameters*/ undefined!, // TODO: GH#18217 @@ -158,13 +161,13 @@ namespace ts.codefix { ); } - function generateSetAccessor(fieldName: AcceptedNameType, accessorName: AcceptedNameType, type: TypeNode | undefined, modifiers: ModifiersArray | undefined, isStatic: boolean, container: ContainerDeclaration) { + function generateSetAccessor(fieldName: AcceptedNameType, accessorName: AcceptedNameType, type: TypeNode | undefined, modifiers: NodeArray | undefined, isStatic: boolean, container: ContainerDeclaration) { return factory.createSetAccessorDeclaration( - /*decorators*/ undefined, + RESERVED, modifiers, accessorName, [factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createIdentifier("value"), @@ -182,10 +185,10 @@ namespace ts.codefix { ); } - function updatePropertyDeclaration(changeTracker: textChanges.ChangeTracker, file: SourceFile, declaration: PropertyDeclaration, type: TypeNode | undefined, fieldName: AcceptedNameType, modifiers: ModifiersArray | undefined) { + function updatePropertyDeclaration(changeTracker: textChanges.ChangeTracker, file: SourceFile, declaration: PropertyDeclaration, type: TypeNode | undefined, fieldName: AcceptedNameType, modifiers: readonly ModifierLike[] | undefined) { const property = factory.updatePropertyDeclaration( declaration, - declaration.decorators, + RESERVED, modifiers, fieldName, declaration.questionToken || declaration.exclamationToken, @@ -200,7 +203,7 @@ namespace ts.codefix { changeTracker.replacePropertyAssignment(file, declaration, assignment); } - function updateFieldDeclaration(changeTracker: textChanges.ChangeTracker, file: SourceFile, declaration: AcceptedDeclaration, type: TypeNode | undefined, fieldName: AcceptedNameType, modifiers: ModifiersArray | undefined) { + function updateFieldDeclaration(changeTracker: textChanges.ChangeTracker, file: SourceFile, declaration: AcceptedDeclaration, type: TypeNode | undefined, fieldName: AcceptedNameType, modifiers: readonly ModifierLike[] | undefined) { if (isPropertyDeclaration(declaration)) { updatePropertyDeclaration(changeTracker, file, declaration, type, fieldName, modifiers); } @@ -209,7 +212,7 @@ namespace ts.codefix { } else { changeTracker.replaceNode(file, declaration, - factory.updateParameterDeclaration(declaration, declaration.decorators, modifiers, declaration.dotDotDotToken, cast(fieldName, isIdentifier), declaration.questionToken, declaration.type, declaration.initializer)); + factory.updateParameterDeclaration(declaration, RESERVED, modifiers, declaration.dotDotDotToken, cast(fieldName, isIdentifier), declaration.questionToken, declaration.type, declaration.initializer)); } } diff --git a/src/services/codefixes/helpers.ts b/src/services/codefixes/helpers.ts index 28fccba8190e3..a3de7631aec80 100644 --- a/src/services/codefixes/helpers.ts +++ b/src/services/codefixes/helpers.ts @@ -87,7 +87,7 @@ namespace ts.codefix { } } addClassElement(factory.createPropertyDeclaration( - /*decorators*/ undefined, + RESERVED, modifiers, name, optional && (preserveOptional & PreserveOptionalFlags.Property) ? factory.createToken(SyntaxKind.QuestionToken) : undefined, @@ -111,7 +111,7 @@ namespace ts.codefix { for (const accessor of orderedAccessors) { if (isGetAccessorDeclaration(accessor)) { addClassElement(factory.createGetAccessorDeclaration( - /*decorators*/ undefined, + RESERVED, modifiers, name, emptyArray, @@ -123,7 +123,7 @@ namespace ts.codefix { const parameter = getSetAccessorValueParameter(accessor); const parameterName = parameter && isIdentifier(parameter.name) ? idText(parameter.name) : undefined; addClassElement(factory.createSetAccessorDeclaration( - /*decorators*/ undefined, + RESERVED, modifiers, name, createDummyParameters(1, [parameterName], [typeNode], 1, /*inJs*/ false), @@ -245,7 +245,7 @@ namespace ts.codefix { } return factory.updateParameterDeclaration( parameterDecl, - parameterDecl.decorators, + RESERVED, parameterDecl.modifiers, parameterDecl.dotDotDotToken, parameterDecl.name, @@ -275,7 +275,7 @@ namespace ts.codefix { return factory.updateArrowFunction(signatureDeclaration, modifiers, typeParameters, parameters, type, signatureDeclaration.equalsGreaterThanToken, body ?? signatureDeclaration.body); } if (isMethodDeclaration(signatureDeclaration)) { - return factory.updateMethodDeclaration(signatureDeclaration, /* decorators */ undefined, modifiers, asteriskToken, name ?? factory.createIdentifier(""), questionToken, typeParameters, parameters, type, body); + return factory.updateMethodDeclaration(signatureDeclaration, RESERVED, modifiers, asteriskToken, name ?? factory.createIdentifier(""), questionToken, typeParameters, parameters, type, body); } return undefined; } @@ -320,7 +320,7 @@ namespace ts.codefix { switch (kind) { case SyntaxKind.MethodDeclaration: return factory.createMethodDeclaration( - /*decorators*/ undefined, + RESERVED, modifiers, asteriskToken, name, @@ -341,7 +341,7 @@ namespace ts.codefix { ); case SyntaxKind.FunctionDeclaration: return factory.createFunctionDeclaration( - /*decorators*/ undefined, + RESERVED, modifiers, asteriskToken, name, @@ -372,7 +372,7 @@ namespace ts.codefix { const parameters: ParameterDeclaration[] = []; for (let i = 0; i < argCount; i++) { const newParameter = factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ names && names[i] || `arg${i}`, @@ -417,7 +417,7 @@ namespace ts.codefix { if (someSigHasRestParameter) { const restParameter = factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.createToken(SyntaxKind.DotDotDotToken), maxArgsParameterSymbolNames[maxNonRestArgs] || "rest", @@ -456,7 +456,7 @@ namespace ts.codefix { body: Block | undefined ): MethodDeclaration { return factory.createMethodDeclaration( - /*decorators*/ undefined, + RESERVED, modifiers, /*asteriskToken*/ undefined, name, diff --git a/src/services/codefixes/importFixes.ts b/src/services/codefixes/importFixes.ts index e277a7d4e8918..403bd0c738256 100644 --- a/src/services/codefixes/importFixes.ts +++ b/src/services/codefixes/importFixes.ts @@ -1256,13 +1256,13 @@ namespace ts.codefix { if (namespaceLikeImport) { const declaration = namespaceLikeImport.importKind === ImportKind.CommonJS ? factory.createImportEqualsDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, needsTypeOnly(namespaceLikeImport), factory.createIdentifier(namespaceLikeImport.name), factory.createExternalModuleReference(quotedModuleSpecifier)) : factory.createImportDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.createImportClause( needsTypeOnly(namespaceLikeImport), diff --git a/src/services/codefixes/requireInTs.ts b/src/services/codefixes/requireInTs.ts index da3bbd0b253b7..98572d906d242 100644 --- a/src/services/codefixes/requireInTs.ts +++ b/src/services/codefixes/requireInTs.ts @@ -24,8 +24,8 @@ namespace ts.codefix { function doChange(changes: textChanges.ChangeTracker, sourceFile: SourceFile, info: Info) { const { allowSyntheticDefaults, defaultImportName, namedImports, statement, required } = info; changes.replaceNode(sourceFile, statement, defaultImportName && !allowSyntheticDefaults - ? factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, defaultImportName, factory.createExternalModuleReference(required)) - : factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, namedImports), required, /*assertClause*/ undefined)); + ? factory.createImportEqualsDeclaration(RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, defaultImportName, factory.createExternalModuleReference(required)) + : factory.createImportDeclaration(RESERVED, /*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, namedImports), required, /*assertClause*/ undefined)); } interface Info { diff --git a/src/services/codefixes/splitTypeOnlyImport.ts b/src/services/codefixes/splitTypeOnlyImport.ts index d4138bf20e892..d72e91e27b23d 100644 --- a/src/services/codefixes/splitTypeOnlyImport.ts +++ b/src/services/codefixes/splitTypeOnlyImport.ts @@ -29,14 +29,14 @@ namespace ts.codefix { const importClause = Debug.checkDefined(importDeclaration.importClause); changes.replaceNode(context.sourceFile, importDeclaration, factory.updateImportDeclaration( importDeclaration, - importDeclaration.decorators, + RESERVED, importDeclaration.modifiers, factory.updateImportClause(importClause, importClause.isTypeOnly, importClause.name, /*namedBindings*/ undefined), importDeclaration.moduleSpecifier, importDeclaration.assertClause)); changes.insertNodeAfter(context.sourceFile, importDeclaration, factory.createImportDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.updateImportClause(importClause, importClause.isTypeOnly, /*name*/ undefined, importClause.namedBindings), importDeclaration.moduleSpecifier, diff --git a/src/services/completions.ts b/src/services/completions.ts index 50bfad2d5e4ed..111f61683f1b1 100644 --- a/src/services/completions.ts +++ b/src/services/completions.ts @@ -1046,7 +1046,7 @@ namespace ts.Completions { span = createTextSpanFromNode(contextToken); } if (isPropertyDeclaration(contextToken.parent)) { - modifiers |= modifiersToFlags(contextToken.parent.modifiers); + modifiers |= modifiersToFlags(contextToken.parent.modifiers) & ModifierFlags.Modifier; span = createTextSpanFromNode(contextToken.parent); } return { modifiers, span }; @@ -1176,7 +1176,7 @@ namespace ts.Completions { const parameters = typeNode.parameters.map(typedParam => factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, typedParam.dotDotDotToken, typedParam.name, @@ -1185,7 +1185,7 @@ namespace ts.Completions { typedParam.initializer, )); return factory.createMethodDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*asteriskToken*/ undefined, name, diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 5a9948cd35f72..4145c8428522e 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -417,7 +417,7 @@ namespace ts.formatting { if (formattingScanner.isOnToken()) { const startLine = sourceFile.getLineAndCharacterOfPosition(enclosingNode.getStart(sourceFile)).line; let undecoratedStartLine = startLine; - if (enclosingNode.decorators) { + if (hasDecorators(enclosingNode)) { undecoratedStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(enclosingNode, sourceFile)).line; } @@ -539,9 +539,11 @@ namespace ts.formatting { } function getFirstNonDecoratorTokenOfNode(node: Node) { - if (node.modifiers && node.modifiers.length) { - return node.modifiers[0].kind; + if (canHaveModifiers(node)) { + const modifier = find(node.modifiers, isModifier, findIndex(node.modifiers, isDecorator)); + if (modifier) return modifier.kind; } + switch (node.kind) { case SyntaxKind.ClassDeclaration: return SyntaxKind.ClassKeyword; case SyntaxKind.InterfaceDeclaration: return SyntaxKind.InterfaceKeyword; @@ -631,7 +633,7 @@ namespace ts.formatting { // if token line equals to the line of containing node (this is a first token in the node) - use node indentation return nodeStartLine !== line // if this token is the first token following the list of decorators, we do not need to indent - && !(node.decorators && kind === getFirstNonDecoratorTokenOfNode(node)); + && !(hasDecorators(node) && kind === getFirstNonDecoratorTokenOfNode(node)); } function getDelta(child: TextRangeWithKind) { @@ -696,7 +698,7 @@ namespace ts.formatting { const childStartLine = sourceFile.getLineAndCharacterOfPosition(childStartPos).line; let undecoratedChildStartLine = childStartLine; - if (child.decorators) { + if (hasDecorators(child)) { undecoratedChildStartLine = sourceFile.getLineAndCharacterOfPosition(getNonDecoratorTokenPosOfNode(child, sourceFile)).line; } diff --git a/src/services/formatting/rules.ts b/src/services/formatting/rules.ts index 76a0d34853153..76cd5aa6e4f8e 100644 --- a/src/services/formatting/rules.ts +++ b/src/services/formatting/rules.ts @@ -724,7 +724,7 @@ namespace ts.formatting { function isEndOfDecoratorContextOnSameLine(context: FormattingContext): boolean { return context.TokensAreOnSameLine() && - !!context.contextNode.decorators && + hasDecorators(context.contextNode) && nodeIsInDecoratorContext(context.currentTokenParent) && !nodeIsInDecoratorContext(context.nextTokenParent); } diff --git a/src/services/getEditsForFileRename.ts b/src/services/getEditsForFileRename.ts index 369f8e8e23f07..5120560da4cee 100644 --- a/src/services/getEditsForFileRename.ts +++ b/src/services/getEditsForFileRename.ts @@ -184,7 +184,7 @@ namespace ts { ): ToImport | undefined { if (importedModuleSymbol) { // `find` should succeed because we checked for ambient modules before calling this function. - const oldFileName = find(importedModuleSymbol.declarations!, isSourceFile)!.fileName; + const oldFileName = find(importedModuleSymbol.declarations, isSourceFile)!.fileName; const newFileName = oldToNew(oldFileName); return newFileName === undefined ? { newFileName: oldFileName, updated: false } : { newFileName, updated: true }; } diff --git a/src/services/goToDefinition.ts b/src/services/goToDefinition.ts index b1c8ec28c1b8d..7da251c9b8f59 100644 --- a/src/services/goToDefinition.ts +++ b/src/services/goToDefinition.ts @@ -366,7 +366,7 @@ namespace ts.GoToDefinition { // Applicable only if we are in a new expression, or we are on a constructor declaration // and in either case the symbol has a construct signature definition, i.e. class if (symbol.flags & SymbolFlags.Class && !(symbol.flags & (SymbolFlags.Function | SymbolFlags.Variable)) && (isNewExpressionTarget(node) || node.kind === SyntaxKind.ConstructorKeyword)) { - const cls = find(filteredDeclarations!, isClassLike) || Debug.fail("Expected declaration to have at least one class-like declaration"); + const cls = find(filteredDeclarations, isClassLike) || Debug.fail("Expected declaration to have at least one class-like declaration"); return getSignatureDefinition(cls.members, /*selectConstructors*/ true); } } diff --git a/src/services/importTracker.ts b/src/services/importTracker.ts index a3fcfb76680de..0ca2d33caf9eb 100644 --- a/src/services/importTracker.ts +++ b/src/services/importTracker.ts @@ -158,7 +158,7 @@ namespace ts.FindAllReferences { function isExported(node: Node, stopAtAmbientModule = false) { return findAncestor(node, node => { if (stopAtAmbientModule && isAmbientModuleDeclaration(node)) return "quit"; - return some(node.modifiers, mod => mod.kind === SyntaxKind.ExportKeyword); + return canHaveModifiers(node) && some(node.modifiers, isExportModifier); }); } diff --git a/src/services/navigationBar.ts b/src/services/navigationBar.ts index 6b0e4869eb1a1..9658d795ee5b6 100644 --- a/src/services/navigationBar.ts +++ b/src/services/navigationBar.ts @@ -546,7 +546,7 @@ namespace ts.NavigationBar { if (ctorFunction !== undefined) { const ctorNode = setTextRange( - factory.createConstructorDeclaration(/* decorators */ undefined, /* modifiers */ undefined, [], /* body */ undefined), + factory.createConstructorDeclaration(RESERVED, /* modifiers */ undefined, [], /* body */ undefined), ctorFunction); const ctor = emptyNavigationBarNode(ctorNode); ctor.indent = a.indent + 1; @@ -564,7 +564,7 @@ namespace ts.NavigationBar { } lastANode = a.node = setTextRange(factory.createClassDeclaration( - /* decorators */ undefined, + RESERVED, /* modifiers */ undefined, a.name as Identifier || factory.createIdentifier("__class__"), /* typeParameters */ undefined, @@ -592,7 +592,7 @@ namespace ts.NavigationBar { else { if (!a.additionalNodes) a.additionalNodes = []; a.additionalNodes.push(setTextRange(factory.createClassDeclaration( - /* decorators */ undefined, + RESERVED, /* modifiers */ undefined, a.name as Identifier || factory.createIdentifier("__class__"), /* typeParameters */ undefined, diff --git a/src/services/organizeImports.ts b/src/services/organizeImports.ts index 7533a54893397..48aa479ddda4b 100644 --- a/src/services/organizeImports.ts +++ b/src/services/organizeImports.ts @@ -185,7 +185,7 @@ namespace ts.OrganizeImports { // If we’re in a declaration file, it’s safe to remove the import clause from it if (sourceFile.isDeclarationFile) { usedImports.push(factory.createImportDeclaration( - importDecl.decorators, + RESERVED, importDecl.modifiers, /*importClause*/ undefined, moduleSpecifier, @@ -392,7 +392,7 @@ namespace ts.OrganizeImports { coalescedExports.push( factory.updateExportDeclaration( exportDecl, - exportDecl.decorators, + RESERVED, exportDecl.modifiers, exportDecl.isTypeOnly, exportDecl.exportClause && ( @@ -445,7 +445,7 @@ namespace ts.OrganizeImports { return factory.updateImportDeclaration( importDeclaration, - importDeclaration.decorators, + RESERVED, importDeclaration.modifiers, factory.updateImportClause(importDeclaration.importClause!, importDeclaration.importClause!.isTypeOnly, name, namedBindings), // TODO: GH#18217 importDeclaration.moduleSpecifier, diff --git a/src/services/refactors/convertArrowFunctionOrFunctionExpression.ts b/src/services/refactors/convertArrowFunctionOrFunctionExpression.ts index ea0c72a4dd684..03f36e33bb868 100644 --- a/src/services/refactors/convertArrowFunctionOrFunctionExpression.ts +++ b/src/services/refactors/convertArrowFunctionOrFunctionExpression.ts @@ -216,7 +216,7 @@ namespace ts.refactor.convertArrowFunctionOrFunctionExpression { const modifiersFlags = (getCombinedModifierFlags(variableDeclaration) & ModifierFlags.Export) | getEffectiveModifierFlags(func); const modifiers = factory.createModifiersFromModifierFlags(modifiersFlags); - const newNode = factory.createFunctionDeclaration(func.decorators, length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); + const newNode = factory.createFunctionDeclaration(RESERVED, length(modifiers) ? modifiers : undefined, func.asteriskToken, name, func.typeParameters, func.parameters, func.type, body); if (variableDeclarationList.declarations.length === 1) { return textChanges.ChangeTracker.with(context, t => t.replaceNode(file, statement, newNode)); diff --git a/src/services/refactors/convertExport.ts b/src/services/refactors/convertExport.ts index 738731a5c8aca..fcacd9b4ed36d 100644 --- a/src/services/refactors/convertExport.ts +++ b/src/services/refactors/convertExport.ts @@ -125,7 +125,7 @@ namespace ts.refactor { if (isExportAssignment(exportNode) && !exportNode.isExportEquals) { const exp = exportNode.expression as Identifier; const spec = makeExportSpecifier(exp.text, exp.text); - changes.replaceNode(exportingSourceFile, exportNode, factory.createExportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([spec]))); + changes.replaceNode(exportingSourceFile, exportNode, factory.createExportDeclaration(RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, factory.createNamedExports([spec]))); } else { changes.delete(exportingSourceFile, Debug.checkDefined(findModifier(exportNode, SyntaxKind.DefaultKeyword), "Should find a default keyword in modifier list")); @@ -214,7 +214,7 @@ namespace ts.refactor { } case SyntaxKind.ImportType: const importTypeNode = parent as ImportTypeNode; - changes.replaceNode(importingSourceFile, parent, factory.createImportTypeNode(importTypeNode.argument, factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf)); + changes.replaceNode(importingSourceFile, parent, factory.createImportTypeNode(importTypeNode.argument, importTypeNode.assertions, factory.createIdentifier(exportName), importTypeNode.typeArguments, importTypeNode.isTypeOf)); break; default: Debug.failBadSyntaxKind(parent); diff --git a/src/services/refactors/convertImport.ts b/src/services/refactors/convertImport.ts index 01333162abb14..1da6a6c6493b4 100644 --- a/src/services/refactors/convertImport.ts +++ b/src/services/refactors/convertImport.ts @@ -226,7 +226,7 @@ namespace ts.refactor { } function updateImport(old: ImportDeclaration, defaultImportName: Identifier | undefined, elements: readonly ImportSpecifier[] | undefined): ImportDeclaration { - return factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, + return factory.createImportDeclaration(RESERVED, /*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, defaultImportName, elements && elements.length ? factory.createNamedImports(elements) : undefined), old.moduleSpecifier, /*assertClause*/ undefined); } } diff --git a/src/services/refactors/convertOverloadListToSingleSignature.ts b/src/services/refactors/convertOverloadListToSingleSignature.ts index 83c071c70ac48..289ea547199c1 100644 --- a/src/services/refactors/convertOverloadListToSingleSignature.ts +++ b/src/services/refactors/convertOverloadListToSingleSignature.ts @@ -51,7 +51,7 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { case SyntaxKind.MethodDeclaration: { updated = factory.updateMethodDeclaration( lastDeclaration, - lastDeclaration.decorators, + RESERVED, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, @@ -75,7 +75,7 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { case SyntaxKind.Constructor: { updated = factory.updateConstructorDeclaration( lastDeclaration, - lastDeclaration.decorators, + RESERVED, lastDeclaration.modifiers, getNewParametersForCombinedSignature(signatureDecls), lastDeclaration.body @@ -94,7 +94,7 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { case SyntaxKind.FunctionDeclaration: { updated = factory.updateFunctionDeclaration( lastDeclaration, - lastDeclaration.decorators, + RESERVED, lastDeclaration.modifiers, lastDeclaration.asteriskToken, lastDeclaration.name, @@ -126,7 +126,7 @@ namespace ts.refactor.addOrRemoveBracesToArrowFunction { } return factory.createNodeArray([ factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.createToken(SyntaxKind.DotDotDotToken), "args", @@ -209,7 +209,7 @@ ${newComment.split("\n").map(c => ` * ${c}`).join("\n")} return; } const signatureDecls = decls as (MethodSignature | MethodDeclaration | CallSignatureDeclaration | ConstructorDeclaration | ConstructSignatureDeclaration | FunctionDeclaration)[]; - if (some(signatureDecls, d => !!d.typeParameters || some(d.parameters, p => !!p.decorators || !!p.modifiers || !isIdentifier(p.name)))) { + if (some(signatureDecls, d => !!d.typeParameters || some(d.parameters, p => !!p.modifiers || !isIdentifier(p.name)))) { return; } const signatures = mapDefined(signatureDecls, d => checker.getSignatureFromDeclaration(d)); diff --git a/src/services/refactors/convertParamsToDestructuredObject.ts b/src/services/refactors/convertParamsToDestructuredObject.ts index 5fcd96a801870..894f016814e91 100644 --- a/src/services/refactors/convertParamsToDestructuredObject.ts +++ b/src/services/refactors/convertParamsToDestructuredObject.ts @@ -404,7 +404,7 @@ namespace ts.refactor.convertParamsToDestructuredObject { const type = checker.getTypeAtLocation(parameterDeclaration); if (!checker.isArrayType(type) && !checker.isTupleType(type)) return false; } - return !parameterDeclaration.modifiers && !parameterDeclaration.decorators && isIdentifier(parameterDeclaration.name); + return !parameterDeclaration.modifiers && isIdentifier(parameterDeclaration.name); } function isValidVariableDeclaration(node: Node): node is ValidVariableDeclaration { @@ -474,7 +474,7 @@ namespace ts.refactor.convertParamsToDestructuredObject { } const objectParameter = factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, objectParameterName, @@ -485,7 +485,7 @@ namespace ts.refactor.convertParamsToDestructuredObject { if (hasThisParameter(functionDeclaration.parameters)) { const thisParameter = functionDeclaration.parameters[0]; const newThisParameter = factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, thisParameter.name, diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index 6e17babb6fea5..f3cc2778ddc6a 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -887,7 +887,7 @@ namespace ts.refactor.extractSymbol { } const paramDecl = factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ name, @@ -938,7 +938,7 @@ namespace ts.refactor.extractSymbol { modifiers.push(factory.createModifier(SyntaxKind.AsyncKeyword)); } newFunction = factory.createMethodDeclaration( - /*decorators*/ undefined, + RESERVED, modifiers.length ? modifiers : undefined, range.facts & RangeFacts.IsGenerator ? factory.createToken(SyntaxKind.AsteriskToken) : undefined, functionName, @@ -953,7 +953,7 @@ namespace ts.refactor.extractSymbol { if (callThis) { parameters.unshift( factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, /*name*/ "this", @@ -968,7 +968,7 @@ namespace ts.refactor.extractSymbol { ); } newFunction = factory.createFunctionDeclaration( - /*decorators*/ undefined, + RESERVED, range.facts & RangeFacts.IsAsyncFunction ? [factory.createToken(SyntaxKind.AsyncKeyword)] : undefined, range.facts & RangeFacts.IsGenerator ? factory.createToken(SyntaxKind.AsteriskToken) : undefined, functionName, @@ -1212,7 +1212,7 @@ namespace ts.refactor.extractSymbol { modifiers.push(factory.createModifier(SyntaxKind.ReadonlyKeyword)); const newVariable = factory.createPropertyDeclaration( - /*decorators*/ undefined, + RESERVED, modifiers, localNameText, /*questionToken*/ undefined, @@ -1324,7 +1324,7 @@ namespace ts.refactor.extractSymbol { if (paramType === checker.getAnyType()) hasAny = true; parameters.push(factory.updateParameterDeclaration(p, - p.decorators, p.modifiers, p.dotDotDotToken, + RESERVED, p.modifiers, p.dotDotDotToken, p.name, p.questionToken, p.type || checker.typeToTypeNode(paramType, scope, NodeBuilderFlags.NoTruncation), p.initializer)); } } @@ -1334,7 +1334,7 @@ namespace ts.refactor.extractSymbol { if (hasAny) return { variableType, initializer }; variableType = undefined; if (isArrowFunction(initializer)) { - initializer = factory.updateArrowFunction(initializer, node.modifiers, initializer.typeParameters, + initializer = factory.updateArrowFunction(initializer, canHaveModifiers(node) ? getModifiers(node) : undefined, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, NodeBuilderFlags.NoTruncation), initializer.equalsGreaterThanToken, @@ -1348,7 +1348,7 @@ namespace ts.refactor.extractSymbol { if ((!firstParameter || (isIdentifier(firstParameter.name) && firstParameter.name.escapedText !== "this"))) { const thisType = checker.getTypeOfSymbolAtLocation(functionSignature.thisParameter, node); parameters.splice(0, 0, factory.createParameterDeclaration( - /* decorators */ undefined, + RESERVED, /* modifiers */ undefined, /* dotDotDotToken */ undefined, "this", @@ -1357,7 +1357,7 @@ namespace ts.refactor.extractSymbol { )); } } - initializer = factory.updateFunctionExpression(initializer, node.modifiers, initializer.asteriskToken, + initializer = factory.updateFunctionExpression(initializer, canHaveModifiers(node) ? getModifiers(node) : undefined, initializer.asteriskToken, initializer.name, initializer.typeParameters, parameters, initializer.type || checker.typeToTypeNode(functionSignature.getReturnType(), scope, NodeBuilderFlags.NoTruncation), diff --git a/src/services/refactors/extractType.ts b/src/services/refactors/extractType.ts index ac6ab73963b31..77665489e82de 100644 --- a/src/services/refactors/extractType.ts +++ b/src/services/refactors/extractType.ts @@ -200,7 +200,7 @@ namespace ts.refactor { const { firstStatement, selection, typeParameters } = info; const newTypeNode = factory.createTypeAliasDeclaration( - /* decorators */ undefined, + RESERVED, /* modifiers */ undefined, name, typeParameters.map(id => factory.updateTypeParameterDeclaration(id, id.modifiers, id.name, id.constraint, /* defaultType */ undefined)), @@ -214,7 +214,7 @@ namespace ts.refactor { const { firstStatement, selection, typeParameters, typeElements } = info; const newTypeNode = factory.createInterfaceDeclaration( - /* decorators */ undefined, + RESERVED, /* modifiers */ undefined, name, typeParameters, diff --git a/src/services/refactors/moveToNewFile.ts b/src/services/refactors/moveToNewFile.ts index 2e96d5aa95b4f..55a44abd3eb0b 100644 --- a/src/services/refactors/moveToNewFile.ts +++ b/src/services/refactors/moveToNewFile.ts @@ -256,12 +256,13 @@ namespace ts.refactor { switch (node.kind) { case SyntaxKind.ImportDeclaration: return factory.createImportDeclaration( - /*decorators*/ undefined, /*modifiers*/ undefined, + RESERVED, + /*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, /*name*/ undefined, factory.createNamespaceImport(newNamespaceId)), newModuleString, /*assertClause*/ undefined); case SyntaxKind.ImportEqualsDeclaration: - return factory.createImportEqualsDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, factory.createExternalModuleReference(newModuleString)); + return factory.createImportEqualsDeclaration(RESERVED, /*modifiers*/ undefined, /*isTypeOnly*/ false, newNamespaceId, factory.createExternalModuleReference(newModuleString)); case SyntaxKind.VariableDeclaration: return factory.createVariableDeclaration(newNamespaceId, /*exclamationToken*/ undefined, /*type*/ undefined, createRequireCall(newModuleString)); default: @@ -592,7 +593,7 @@ namespace ts.refactor { const defaultImport = clause.name && keep(clause.name) ? clause.name : undefined; const namedBindings = clause.namedBindings && filterNamedBindings(clause.namedBindings, keep); return defaultImport || namedBindings - ? factory.createImportDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) + ? factory.createImportDeclaration(RESERVED, /*modifiers*/ undefined, factory.createImportClause(/*isTypeOnly*/ false, defaultImport, namedBindings), moduleSpecifier, /*assertClause*/ undefined) : undefined; } case SyntaxKind.ImportEqualsDeclaration: @@ -782,24 +783,25 @@ namespace ts.refactor { return useEs6Exports ? [addEs6Export(decl)] : addCommonjsExport(decl); } function addEs6Export(d: TopLevelDeclarationStatement): TopLevelDeclarationStatement { - const modifiers = concatenate([factory.createModifier(SyntaxKind.ExportKeyword)], d.modifiers); + const modifiers = canHaveModifiers(d) ? concatenate([factory.createModifier(SyntaxKind.ExportKeyword)], getModifiers(d)) : undefined; switch (d.kind) { case SyntaxKind.FunctionDeclaration: - return factory.updateFunctionDeclaration(d, d.decorators, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); + return factory.updateFunctionDeclaration(d, RESERVED, modifiers, d.asteriskToken, d.name, d.typeParameters, d.parameters, d.type, d.body); case SyntaxKind.ClassDeclaration: - return factory.updateClassDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); + const decorators = canHaveDecorators(d) ? getDecorators(d) : undefined; + return factory.updateClassDeclaration(d, RESERVED, concatenate(decorators, modifiers), d.name, d.typeParameters, d.heritageClauses, d.members); case SyntaxKind.VariableStatement: return factory.updateVariableStatement(d, modifiers, d.declarationList); case SyntaxKind.ModuleDeclaration: - return factory.updateModuleDeclaration(d, d.decorators, modifiers, d.name, d.body); + return factory.updateModuleDeclaration(d, RESERVED, modifiers, d.name, d.body); case SyntaxKind.EnumDeclaration: - return factory.updateEnumDeclaration(d, d.decorators, modifiers, d.name, d.members); + return factory.updateEnumDeclaration(d, RESERVED, modifiers, d.name, d.members); case SyntaxKind.TypeAliasDeclaration: - return factory.updateTypeAliasDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.type); + return factory.updateTypeAliasDeclaration(d, RESERVED, modifiers, d.name, d.typeParameters, d.type); case SyntaxKind.InterfaceDeclaration: - return factory.updateInterfaceDeclaration(d, d.decorators, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); + return factory.updateInterfaceDeclaration(d, RESERVED, modifiers, d.name, d.typeParameters, d.heritageClauses, d.members); case SyntaxKind.ImportEqualsDeclaration: - return factory.updateImportEqualsDeclaration(d, d.decorators, modifiers, d.isTypeOnly, d.name, d.moduleReference); + return factory.updateImportEqualsDeclaration(d, RESERVED, modifiers, d.isTypeOnly, d.name, d.moduleReference); case SyntaxKind.ExpressionStatement: return Debug.fail(); // Shouldn't try to add 'export' keyword to `exports.x = ...` default: diff --git a/src/services/utilities.ts b/src/services/utilities.ts index 16d406f7d259d..22639847ab583 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -768,7 +768,7 @@ namespace ts { if (isFunctionDeclaration(node)) { // for class and function declarations, use the `default` modifier // when the declaration is unnamed. - const defaultModifier = find(node.modifiers!, isDefaultModifier); + const defaultModifier = find(node.modifiers, isDefaultModifier); if (defaultModifier) return defaultModifier; } if (isFunctionExpression(node)) { @@ -901,7 +901,7 @@ namespace ts { // // NOTE: If the node is a modifier, we don't adjust its location if it is the `default` modifier as that is handled // specially by `getSymbolAtLocation`. - if (isModifier(node) && (forRename || node.kind !== SyntaxKind.DefaultKeyword) ? contains(parent.modifiers, node) : + if (isModifier(node) && (forRename || node.kind !== SyntaxKind.DefaultKeyword) ? canHaveModifiers(parent) && contains(parent.modifiers, node) : node.kind === SyntaxKind.ClassKeyword ? isClassDeclaration(parent) || isClassExpression(node) : node.kind === SyntaxKind.FunctionKeyword ? isFunctionDeclaration(parent) || isFunctionExpression(node) : node.kind === SyntaxKind.InterfaceKeyword ? isInterfaceDeclaration(parent) : @@ -1934,7 +1934,7 @@ namespace ts { export function makeImport(defaultImport: Identifier | undefined, namedImports: readonly ImportSpecifier[] | undefined, moduleSpecifier: string | Expression, quotePreference: QuotePreference, isTypeOnly?: boolean): ImportDeclaration { return factory.createImportDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, defaultImport || namedImports ? factory.createImportClause(!!isTypeOnly, defaultImport, namedImports && namedImports.length ? factory.createNamedImports(namedImports) : undefined) @@ -2029,7 +2029,7 @@ namespace ts { } export function findModifier(node: Node, kind: Modifier["kind"]): Modifier | undefined { - return node.modifiers && find(node.modifiers, m => m.kind === kind); + return canHaveModifiers(node) ? find(node.modifiers, (m): m is Modifier => m.kind === kind) : undefined; } export function insertImports(changes: textChanges.ChangeTracker, sourceFile: SourceFile, imports: AnyImportOrRequireStatement | readonly AnyImportOrRequireStatement[], blankLineBetween: boolean): void { diff --git a/src/testRunner/tsconfig.json b/src/testRunner/tsconfig.json index 599aaa19a8615..05b0583bedc22 100644 --- a/src/testRunner/tsconfig.json +++ b/src/testRunner/tsconfig.json @@ -22,8 +22,9 @@ { "path": "../server", "prepend": true }, { "path": "../webServer", "prepend": true }, { "path": "../typingsInstallerCore", "prepend": true }, + { "path": "../deprecatedCompat", "prepend": true }, { "path": "../harness", "prepend": true }, - { "path": "../loggedIO", "prepend": true } + { "path": "../loggedIO", "prepend": true }, ], "files": [ diff --git a/src/testRunner/unittests/factory.ts b/src/testRunner/unittests/factory.ts index a413881c07d3e..2442ead8ba1c8 100644 --- a/src/testRunner/unittests/factory.ts +++ b/src/testRunner/unittests/factory.ts @@ -7,7 +7,7 @@ namespace ts { it("parenthesizes default export if necessary", () => { function checkExpression(expression: Expression) { const node = factory.createExportAssignment( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*isExportEquals*/ false, expression, @@ -15,8 +15,8 @@ namespace ts { assertSyntaxKind(node.expression, SyntaxKind.ParenthesizedExpression); } - const clazz = factory.createClassExpression(/*decorators*/ undefined, /*modifiers*/ undefined, "C", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [ - factory.createPropertyDeclaration(/*decorators*/ undefined, [factory.createToken(SyntaxKind.StaticKeyword)], "prop", /*questionOrExclamationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral("1")), + const clazz = factory.createClassExpression(RESERVED, /*modifiers*/ undefined, "C", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [ + factory.createPropertyDeclaration(RESERVED, [factory.createToken(SyntaxKind.StaticKeyword)], "prop", /*questionOrExclamationToken*/ undefined, /*type*/ undefined, factory.createStringLiteral("1")), ]); checkExpression(clazz); checkExpression(factory.createPropertyAccessExpression(clazz, "prop")); diff --git a/src/testRunner/unittests/printer.ts b/src/testRunner/unittests/printer.ts index 51e1727e7ef82..1e0c9dd2c2258 100644 --- a/src/testRunner/unittests/printer.ts +++ b/src/testRunner/unittests/printer.ts @@ -148,13 +148,13 @@ namespace ts { printsCorrectly("class", {}, printer => printer.printNode( EmitHint.Unspecified, factory.createClassDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*name*/ factory.createIdentifier("C"), /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [factory.createPropertyDeclaration( - /*decorators*/ undefined, + RESERVED, factory.createNodeArray([factory.createToken(SyntaxKind.PublicKeyword)]), factory.createIdentifier("prop"), /*questionToken*/ undefined, @@ -199,7 +199,7 @@ namespace ts { printsCorrectly("emptyGlobalAugmentation", {}, printer => printer.printNode( EmitHint.Unspecified, factory.createModuleDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ [factory.createToken(SyntaxKind.DeclareKeyword)], factory.createIdentifier("global"), factory.createModuleBlock(emptyArray), @@ -210,7 +210,7 @@ namespace ts { printsCorrectly("emptyGlobalAugmentationWithNoDeclareKeyword", {}, printer => printer.printNode( EmitHint.Unspecified, factory.createModuleDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.createIdentifier("global"), factory.createModuleBlock(emptyArray), @@ -222,14 +222,14 @@ namespace ts { printsCorrectly("classWithOptionalMethodAndProperty", {}, printer => printer.printNode( EmitHint.Unspecified, factory.createClassDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ [factory.createToken(SyntaxKind.DeclareKeyword)], /*name*/ factory.createIdentifier("X"), /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [ factory.createMethodDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ factory.createIdentifier("method"), @@ -240,7 +240,7 @@ namespace ts { /*body*/ undefined ), factory.createPropertyDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*name*/ factory.createIdentifier("property"), /*questionToken*/ factory.createToken(SyntaxKind.QuestionToken), @@ -259,7 +259,7 @@ namespace ts { factory.createFunctionTypeNode( /*typeArguments*/ undefined, [factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createIdentifier("args") @@ -269,7 +269,7 @@ namespace ts { factory.createFunctionTypeNode( [factory.createTypeParameterDeclaration(/*modifiers*/ undefined, "T")], [factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createIdentifier("args") @@ -279,7 +279,7 @@ namespace ts { factory.createFunctionTypeNode( /*typeArguments*/ undefined, [factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.createToken(SyntaxKind.DotDotDotToken), factory.createIdentifier("args") @@ -289,7 +289,7 @@ namespace ts { factory.createFunctionTypeNode( /*typeArguments*/ undefined, [factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createIdentifier("args"), @@ -300,7 +300,7 @@ namespace ts { factory.createFunctionTypeNode( /*typeArguments*/ undefined, [factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createIdentifier("args"), @@ -312,7 +312,7 @@ namespace ts { factory.createFunctionTypeNode( /*typeArguments*/ undefined, [factory.createParameterDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*dotDotDotToken*/ undefined, factory.createObjectBindingPattern([]) diff --git a/src/testRunner/unittests/services/textChanges.ts b/src/testRunner/unittests/services/textChanges.ts index 534d57ebf8f08..f12e995ca40a4 100644 --- a/src/testRunner/unittests/services/textChanges.ts +++ b/src/testRunner/unittests/services/textChanges.ts @@ -83,7 +83,7 @@ namespace M runSingleFileTest("extractMethodLike", /*placeOpenBraceOnNewLineForFunctions*/ true, text, /*validateNodes*/ true, (sourceFile, changeTracker) => { const statements = (findChild("foo", sourceFile) as FunctionDeclaration).body!.statements.slice(1); const newFunction = factory.createFunctionDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*asteriskToken*/ undefined, /*name*/ "bar", @@ -182,7 +182,7 @@ var a = 4; // comment 7 } function createTestClass() { return factory.createClassDeclaration( - /*decorators*/ undefined, + RESERVED, [ factory.createToken(SyntaxKind.PublicKeyword) ], @@ -198,7 +198,7 @@ var a = 4; // comment 7 ], [ factory.createPropertyDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, "property1", /*questionToken*/ undefined, @@ -643,7 +643,7 @@ class A { for (let i = 0; i < 11 /*error doesn't occur with fewer nodes*/; ++i) { newNodes.push( // eslint-disable-next-line boolean-trivia - factory.createPropertyDeclaration(undefined, undefined, i + "", undefined, undefined, undefined)); + factory.createPropertyDeclaration(RESERVED, undefined, i + "", undefined, undefined, undefined)); } const insertAfter = findChild("x", sourceFile); for (const newNode of newNodes) { @@ -659,7 +659,7 @@ class A { `; runSingleFileTest("insertNodeAfterInClass1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { // eslint-disable-next-line boolean-trivia - changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), factory.createPropertyDeclaration(undefined, undefined, "a", undefined, factory.createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined)); + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), factory.createPropertyDeclaration(RESERVED, undefined, "a", undefined, factory.createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined)); }); } { @@ -670,7 +670,7 @@ class A { `; runSingleFileTest("insertNodeAfterInClass2", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { // eslint-disable-next-line boolean-trivia - changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), factory.createPropertyDeclaration(undefined, undefined, "a", undefined, factory.createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined)); + changeTracker.insertNodeAfter(sourceFile, findChild("x", sourceFile), factory.createPropertyDeclaration(RESERVED, undefined, "a", undefined, factory.createKeywordTypeNode(SyntaxKind.BooleanKeyword), undefined)); }); } { @@ -703,7 +703,7 @@ class A { `; runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = factory.createPropertyDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.createComputedPropertyName(factory.createNumericLiteral(1)), /*questionToken*/ undefined, @@ -721,7 +721,7 @@ class A { `; runSingleFileTest("insertNodeInClassAfterNodeWithoutSeparator2", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = factory.createPropertyDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.createComputedPropertyName(factory.createNumericLiteral(1)), /*questionToken*/ undefined, @@ -738,7 +738,7 @@ interface A { `; runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator1", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = factory.createPropertyDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.createComputedPropertyName(factory.createNumericLiteral(1)), /*questionToken*/ undefined, @@ -755,7 +755,7 @@ interface A { `; runSingleFileTest("insertNodeInInterfaceAfterNodeWithoutSeparator2", /*placeOpenBraceOnNewLineForFunctions*/ false, text, /*validateNodes*/ false, (sourceFile, changeTracker) => { const newNode = factory.createPropertyDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, factory.createComputedPropertyName(factory.createNumericLiteral(1)), /*questionToken*/ undefined, diff --git a/src/testRunner/unittests/transform.ts b/src/testRunner/unittests/transform.ts index 256a1db2e303e..9b7005c8560d5 100644 --- a/src/testRunner/unittests/transform.ts +++ b/src/testRunner/unittests/transform.ts @@ -232,8 +232,8 @@ namespace ts { const result = factory.updateSourceFile( sourceFile, factory.createNodeArray([ - factory.createClassDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, "Foo", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, /*members*/ undefined!), // TODO: GH#18217 - factory.createModuleDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, factory.createIdentifier("Foo"), factory.createModuleBlock([factory.createEmptyStatement()])) + factory.createClassDeclaration(RESERVED, /*modifiers*/ undefined, "Foo", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, /*members*/ undefined!), // TODO: GH#18217 + factory.createModuleDeclaration(RESERVED, /*modifiers*/ undefined, factory.createIdentifier("Foo"), factory.createModuleBlock([factory.createEmptyStatement()])) ]) ); return result; @@ -277,7 +277,7 @@ namespace ts { const exports = [{ name: "x" }]; const exportSpecifiers = exports.map(e => factory.createExportSpecifier(/*isTypeOnly*/ false, e.name, e.name)); const exportClause = factory.createNamedExports(exportSpecifiers); - const newEd = factory.updateExportDeclaration(ed, ed.decorators, ed.modifiers, ed.isTypeOnly, exportClause, ed.moduleSpecifier, ed.assertClause); + const newEd = factory.updateExportDeclaration(ed, RESERVED, ed.modifiers, ed.isTypeOnly, exportClause, ed.moduleSpecifier, ed.assertClause); return newEd as Node as T; } @@ -307,7 +307,7 @@ namespace ts { function visitNode(sf: SourceFile) { // produce `import * as i0 from './comp'; const importStar = factory.createImportDeclaration( - /*decorators*/ undefined, + RESERVED, /*modifiers*/ undefined, /*importClause*/ factory.createImportClause( /*isTypeOnly*/ false, @@ -339,8 +339,8 @@ namespace ts { }; function visitNode(sf: SourceFile) { // produce `class Foo { @Bar baz() {} }`; - const classDecl = factory.createClassDeclaration([], [], "Foo", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [ - factory.createMethodDeclaration([factory.createDecorator(factory.createIdentifier("Bar"))], [], /**/ undefined, "baz", /**/ undefined, /**/ undefined, [], /**/ undefined, factory.createBlock([])) + const classDecl = factory.createClassDeclaration(RESERVED, /*modifiers*/ undefined, "Foo", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [ + factory.createMethodDeclaration(RESERVED, [factory.createDecorator(factory.createIdentifier("Bar"))], /**/ undefined, "baz", /**/ undefined, /**/ undefined, [], /**/ undefined, factory.createBlock([])) ]); return factory.updateSourceFile(sf, [classDecl]); } @@ -378,9 +378,9 @@ namespace ts { function visitNode(sf: SourceFile) { // produce `class Foo { constructor(@Dec private x) {} }`; // The decorator is required to trigger ts.ts transformations. - const classDecl = factory.createClassDeclaration([], [], "Foo", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [ - factory.createConstructorDeclaration(/*decorators*/ undefined, /*modifiers*/ undefined, [ - factory.createParameterDeclaration(/*decorators*/ [factory.createDecorator(factory.createIdentifier("Dec"))], /*modifiers*/ [factory.createModifier(SyntaxKind.PrivateKeyword)], /*dotDotDotToken*/ undefined, "x")], factory.createBlock([])) + const classDecl = factory.createClassDeclaration(RESERVED, [], "Foo", /*typeParameters*/ undefined, /*heritageClauses*/ undefined, [ + factory.createConstructorDeclaration(RESERVED, /*modifiers*/ undefined, [ + factory.createParameterDeclaration(RESERVED, [factory.createDecorator(factory.createIdentifier("Dec")), factory.createModifier(SyntaxKind.PrivateKeyword)], /*dotDotDotToken*/ undefined, "x")], factory.createBlock([])) ]); return factory.updateSourceFile(sf, [classDecl]); } @@ -556,7 +556,7 @@ module MyModule { if (isMethodDeclaration(node)) { return factory.updateMethodDeclaration( node, - node.decorators, + RESERVED, node.modifiers, node.asteriskToken, factory.createIdentifier("foobar"), @@ -606,18 +606,24 @@ module MyModule { }; function rootTransform(node: T): Node { if (isClassLike(node)) { - const newMembers = [factory.createPropertyDeclaration(/* decorators */ undefined, [factory.createModifier(SyntaxKind.StaticKeyword)], "newField", /* questionOrExclamationToken */ undefined, /* type */ undefined, factory.createStringLiteral("x"))]; + const newMembers = [factory.createPropertyDeclaration(RESERVED, [factory.createModifier(SyntaxKind.StaticKeyword)], "newField", /* questionOrExclamationToken */ undefined, /* type */ undefined, factory.createStringLiteral("x"))]; setSyntheticLeadingComments(newMembers[0], [{ kind: SyntaxKind.MultiLineCommentTrivia, text: "comment", pos: -1, end: -1, hasTrailingNewLine: true }]); return isClassDeclaration(node) ? factory.updateClassDeclaration( - node, node.decorators, - /* modifierFlags */ undefined, node.name, - node.typeParameters, node.heritageClauses, + node, + RESERVED, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, newMembers) : factory.updateClassExpression( - node, node.decorators, - /* modifierFlags */ undefined, node.name, - node.typeParameters, node.heritageClauses, + node, + RESERVED, + node.modifiers, + node.name, + node.typeParameters, + node.heritageClauses, newMembers); } return visitEachChild(node, rootTransform, context); diff --git a/src/testRunner/unittests/tsbuild/helpers.ts b/src/testRunner/unittests/tsbuild/helpers.ts index 803a37e014fc6..5035c2efa92ff 100644 --- a/src/testRunner/unittests/tsbuild/helpers.ts +++ b/src/testRunner/unittests/tsbuild/helpers.ts @@ -378,7 +378,7 @@ interface Symbol { } let expectedIndex = 0; incrementalReadableBuildInfo.program.affectedFilesPendingEmit.forEach(([actualFile]) => { - expectedIndex = findIndex(cleanReadableBuildInfo!.program!.affectedFilesPendingEmit!, ([expectedFile]) => actualFile === expectedFile, expectedIndex); + expectedIndex = findIndex(cleanReadableBuildInfo!.program!.affectedFilesPendingEmit, ([expectedFile]) => actualFile === expectedFile, expectedIndex); if (expectedIndex === -1) { addBaseline( `Incremental build contains ${actualFile} file as pending emit, clean build does not have it: ${outputFile}::`, diff --git a/tests/baselines/reference/api/tsserverlibrary.d.ts b/tests/baselines/reference/api/tsserverlibrary.d.ts index 0fd5bf9e0a933..ee76f79db082d 100644 --- a/tests/baselines/reference/api/tsserverlibrary.d.ts +++ b/tests/baselines/reference/api/tsserverlibrary.d.ts @@ -554,13 +554,15 @@ declare namespace ts { Override = 16384, In = 32768, Out = 65536, + Decorator = 131072, HasComputedFlags = 536870912, AccessibilityModifier = 28, ParameterPropertyModifier = 16476, NonPublicAccessibilityModifier = 24, TypeScriptModifier = 116958, ExportDefault = 513, - All = 125951 + All = 257023, + Modifier = 125951 } export enum JsxFlags { None = 0, @@ -573,8 +575,6 @@ declare namespace ts { export interface Node extends ReadonlyTextRange { readonly kind: SyntaxKind; readonly flags: NodeFlags; - readonly decorators?: NodeArray; - readonly modifiers?: ModifiersArray; readonly parent: Node; } export interface JSDocContainer { @@ -583,7 +583,9 @@ declare namespace ts { export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement; export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; - export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; + export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | EnumMember; + export type HasDecorators = ParameterDeclaration | PropertyDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ClassExpression | ClassDeclaration; + export type HasModifiers = TypeParameterDeclaration | ParameterDeclaration | ConstructorTypeNode | PropertySignature | PropertyDeclaration | MethodSignature | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | IndexSignatureDeclaration | FunctionExpression | ArrowFunction | ClassExpression | VariableStatement | FunctionDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | ExportAssignment | ExportDeclaration; export interface NodeArray extends ReadonlyArray, ReadonlyTextRange { readonly hasTrailingComma: boolean; } @@ -632,6 +634,7 @@ declare namespace ts { /** @deprecated Use `ReadonlyKeyword` instead. */ export type ReadonlyToken = ReadonlyKeyword; export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | InKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; + export type ModifierLike = Modifier | Decorator; export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword; export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword; export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword; @@ -691,6 +694,7 @@ declare namespace ts { export interface TypeParameterDeclaration extends NamedDeclaration { readonly kind: SyntaxKind.TypeParameter; readonly parent: DeclarationWithTypeParameterChildren | InferTypeNode; + readonly modifiers?: NodeArray; readonly name: Identifier; /** Note: Consider calling `getEffectiveConstraintOfTypeParameter` */ readonly constraint?: TypeNode; @@ -700,9 +704,9 @@ declare namespace ts { export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { readonly kind: SignatureDeclaration["kind"]; readonly name?: PropertyName; - readonly typeParameters?: NodeArray; + readonly typeParameters?: NodeArray | undefined; readonly parameters: NodeArray; - readonly type?: TypeNode; + readonly type?: TypeNode | undefined; } export type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { @@ -728,6 +732,7 @@ declare namespace ts { export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { readonly kind: SyntaxKind.Parameter; readonly parent: SignatureDeclaration; + readonly modifiers?: NodeArray; readonly dotDotDotToken?: DotDotDotToken; readonly name: BindingName; readonly questionToken?: QuestionToken; @@ -744,14 +749,15 @@ declare namespace ts { } export interface PropertySignature extends TypeElement, JSDocContainer { readonly kind: SyntaxKind.PropertySignature; + readonly modifiers?: NodeArray; readonly name: PropertyName; readonly questionToken?: QuestionToken; readonly type?: TypeNode; - initializer?: Expression; } export interface PropertyDeclaration extends ClassElement, JSDocContainer { readonly kind: SyntaxKind.PropertyDeclaration; readonly parent: ClassLikeDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; readonly questionToken?: QuestionToken; readonly exclamationToken?: ExclamationToken; @@ -768,16 +774,12 @@ declare namespace ts { readonly kind: SyntaxKind.PropertyAssignment; readonly parent: ObjectLiteralExpression; readonly name: PropertyName; - readonly questionToken?: QuestionToken; - readonly exclamationToken?: ExclamationToken; readonly initializer: Expression; } export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.ShorthandPropertyAssignment; readonly parent: ObjectLiteralExpression; readonly name: Identifier; - readonly questionToken?: QuestionToken; - readonly exclamationToken?: ExclamationToken; readonly equalsToken?: EqualsToken; readonly objectAssignmentInitializer?: Expression; } @@ -812,34 +814,41 @@ declare namespace ts { */ export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; - readonly asteriskToken?: AsteriskToken; - readonly questionToken?: QuestionToken; - readonly exclamationToken?: ExclamationToken; - readonly body?: Block | Expression; + readonly asteriskToken?: AsteriskToken | undefined; + readonly questionToken?: QuestionToken | undefined; + readonly exclamationToken?: ExclamationToken | undefined; + readonly body?: Block | Expression | undefined; } export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; /** @deprecated Use SignatureDeclaration */ export type FunctionLike = SignatureDeclaration; export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { readonly kind: SyntaxKind.FunctionDeclaration; + readonly modifiers?: NodeArray; readonly name?: Identifier; readonly body?: FunctionBody; } export interface MethodSignature extends SignatureDeclarationBase, TypeElement { readonly kind: SyntaxKind.MethodSignature; readonly parent: ObjectTypeDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; } export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.MethodDeclaration; readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly modifiers?: NodeArray | undefined; readonly name: PropertyName; - readonly body?: FunctionBody; + readonly exclamationToken?: undefined; + readonly body?: FunctionBody | undefined; } export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { readonly kind: SyntaxKind.Constructor; readonly parent: ClassLikeDeclaration; - readonly body?: FunctionBody; + readonly modifiers?: NodeArray | undefined; + readonly body?: FunctionBody | undefined; + readonly typeParameters?: undefined; + readonly type?: undefined; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ export interface SemicolonClassElement extends ClassElement { @@ -849,19 +858,25 @@ declare namespace ts { export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.GetAccessor; readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; + readonly typeParameters?: undefined; readonly body?: FunctionBody; } export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.SetAccessor; readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; + readonly typeParameters?: undefined; + readonly type?: undefined; readonly body?: FunctionBody; } export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { readonly kind: SyntaxKind.IndexSignature; readonly parent: ObjectTypeDeclaration; + readonly modifiers?: NodeArray; readonly type: TypeNode; } export interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer { @@ -898,9 +913,11 @@ declare namespace ts { } export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { readonly kind: SyntaxKind.FunctionType; + readonly modifiers?: undefined; } export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { readonly kind: SyntaxKind.ConstructorType; + readonly modifiers?: NodeArray; } export interface NodeWithTypeArguments extends TypeNode { readonly typeArguments?: NodeArray; @@ -1157,11 +1174,13 @@ declare namespace ts { export type ConciseBody = FunctionBody | Expression; export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { readonly kind: SyntaxKind.FunctionExpression; + readonly modifiers?: NodeArray; readonly name?: Identifier; readonly body: FunctionBody; } export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { readonly kind: SyntaxKind.ArrowFunction; + readonly modifiers?: NodeArray; readonly equalsGreaterThanToken: EqualsGreaterThanToken; readonly body: ConciseBody; readonly name: never; @@ -1442,6 +1461,7 @@ declare namespace ts { } export interface VariableStatement extends Statement { readonly kind: SyntaxKind.VariableStatement; + readonly modifiers?: NodeArray; readonly declarationList: VariableDeclarationList; } export interface ExpressionStatement extends Statement { @@ -1558,11 +1578,13 @@ declare namespace ts { } export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { readonly kind: SyntaxKind.ClassDeclaration; + readonly modifiers?: NodeArray; /** May be undefined in `export default class { ... }`. */ readonly name?: Identifier; } export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { readonly kind: SyntaxKind.ClassExpression; + readonly modifiers?: NodeArray; } export type ClassLikeDeclaration = ClassDeclaration | ClassExpression; export interface ClassElement extends NamedDeclaration { @@ -1572,10 +1594,11 @@ declare namespace ts { export interface TypeElement extends NamedDeclaration { _typeElementBrand: any; readonly name?: PropertyName; - readonly questionToken?: QuestionToken; + readonly questionToken?: QuestionToken | undefined; } export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.InterfaceDeclaration; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly typeParameters?: NodeArray; readonly heritageClauses?: NodeArray; @@ -1589,6 +1612,7 @@ declare namespace ts { } export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.TypeAliasDeclaration; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly typeParameters?: NodeArray; readonly type: TypeNode; @@ -1601,6 +1625,7 @@ declare namespace ts { } export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.EnumDeclaration; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly members: NodeArray; } @@ -1609,6 +1634,7 @@ declare namespace ts { export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ModuleDeclaration; readonly parent: ModuleBody | SourceFile; + readonly modifiers?: NodeArray; readonly name: ModuleName; readonly body?: ModuleBody | JSDocNamespaceDeclaration; } @@ -1636,6 +1662,7 @@ declare namespace ts { export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ImportEqualsDeclaration; readonly parent: SourceFile | ModuleBlock; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly isTypeOnly: boolean; readonly moduleReference: ModuleReference; @@ -1648,6 +1675,7 @@ declare namespace ts { export interface ImportDeclaration extends Statement { readonly kind: SyntaxKind.ImportDeclaration; readonly parent: SourceFile | ModuleBlock; + readonly modifiers?: NodeArray; readonly importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ readonly moduleSpecifier: Expression; @@ -1692,6 +1720,7 @@ declare namespace ts { export interface ExportDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ExportDeclaration; readonly parent: SourceFile | ModuleBlock; + readonly modifiers?: NodeArray; readonly isTypeOnly: boolean; /** Will not be assigned in the case of `export * from "foo";` */ readonly exportClause?: NamedExportBindings; @@ -1759,6 +1788,7 @@ declare namespace ts { export interface ExportAssignment extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ExportAssignment; readonly parent: SourceFile; + readonly modifiers?: NodeArray; readonly isExportEquals?: boolean; readonly expression: Expression; } @@ -3402,39 +3432,35 @@ declare namespace ts { createComputedPropertyName(expression: Expression): ComputedPropertyName; updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; - /** @deprecated */ - createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - /** @deprecated */ - updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + createParameterDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + updateParameterDeclaration(node: ParameterDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; createDecorator(expression: Expression): Decorator; updateDecorator(node: Decorator, expression: Expression): Decorator; createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined): PropertySignature; updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined): PropertySignature; - createPropertyDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - updatePropertyDeclaration(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + createPropertyDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + updatePropertyDeclaration(node: PropertyDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; createMethodSignature(modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): MethodSignature; updateMethodSignature(node: MethodSignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): MethodSignature; - createMethodDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - updateMethodDeclaration(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - createConstructorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; - updateConstructorDeclaration(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; - createGetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - updateGetAccessorDeclaration(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - createSetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; - updateSetAccessorDeclaration(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + createMethodDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + updateMethodDeclaration(node: MethodDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + createConstructorDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + updateConstructorDeclaration(node: ConstructorDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + createGetAccessorDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + updateGetAccessorDeclaration(node: GetAccessorDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + createSetAccessorDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + updateSetAccessorDeclaration(node: SetAccessorDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; - updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + createIndexSignature(decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + updateIndexSignature(node: IndexSignatureDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; createTemplateLiteralTypeSpan(type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan; updateTemplateLiteralTypeSpan(node: TemplateLiteralTypeSpan, type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan; - createClassStaticBlockDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; - updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; + createClassStaticBlockDeclaration(decorators: null, modifiers: null, body: Block): ClassStaticBlockDeclaration; + updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: null, modifiers: null, body: Block): ClassStaticBlockDeclaration; createKeywordTypeNode(kind: TKind): KeywordTypeNode; createTypePredicateNode(assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; updateTypePredicateNode(node: TypePredicateNode, assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; @@ -3443,11 +3469,7 @@ declare namespace ts { createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): FunctionTypeNode; updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): FunctionTypeNode; createConstructorTypeNode(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; - /** @deprecated */ - createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; updateConstructorTypeNode(node: ConstructorTypeNode, modifiers: readonly Modifier[] | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): ConstructorTypeNode; - /** @deprecated */ - updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): ConstructorTypeNode; createTypeQueryNode(exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode; updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode; createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; @@ -3470,9 +3492,7 @@ declare namespace ts { updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; createImportTypeNode(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; - updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode; updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, assertions: ImportTypeAssertionContainer | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode; createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; @@ -3552,8 +3572,8 @@ declare namespace ts { updateYieldExpression(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression | undefined): YieldExpression; createSpreadElement(expression: Expression): SpreadElement; updateSpreadElement(node: SpreadElement, expression: Expression): SpreadElement; - createClassExpression(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; - updateClassExpression(node: ClassExpression, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + createClassExpression(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + updateClassExpression(node: ClassExpression, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; createOmittedExpression(): OmittedExpression; createExpressionWithTypeArguments(expression: Expression, typeArguments: readonly TypeNode[] | undefined): ExpressionWithTypeArguments; updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, expression: Expression, typeArguments: readonly TypeNode[] | undefined): ExpressionWithTypeArguments; @@ -3608,28 +3628,28 @@ declare namespace ts { updateVariableDeclaration(node: VariableDeclaration, name: BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; - createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; - updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; - createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; - updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; - createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; - updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; - createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; - updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; - createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + createFunctionDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + updateFunctionDeclaration(node: FunctionDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + createClassDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + updateClassDeclaration(node: ClassDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + createInterfaceDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + createTypeAliasDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + createEnumDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + updateEnumDeclaration(node: EnumDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + createModuleDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + updateModuleDeclaration(node: ModuleDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; createModuleBlock(statements: readonly Statement[]): ModuleBlock; updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause): ImportDeclaration; - updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + createImportEqualsDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + createImportDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause): ImportDeclaration; + updateImportDeclaration(node: ImportDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; createAssertClause(elements: NodeArray, multiLine?: boolean): AssertClause; @@ -3646,10 +3666,10 @@ declare namespace ts { updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; createImportSpecifier(isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; - createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; - updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; + createExportAssignment(decorators: null, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + updateExportAssignment(node: ExportAssignment, decorators: null, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + createExportDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; + updateExportDeclaration(node: ExportDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; createExportSpecifier(isTypeOnly: boolean, propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; @@ -4055,7 +4075,7 @@ declare namespace ts { NoSpaceIfEmpty = 524288, SingleElement = 1048576, SpaceAfterList = 2097152, - Modifiers = 262656, + Modifiers = 2359808, HeritageClauses = 512, SingleLineTypeLiteralMembers = 768, MultiLineTypeLiteralMembers = 32897, @@ -4349,6 +4369,8 @@ declare namespace ts { function symbolName(symbol: Symbol): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined; function getNameOfDeclaration(declaration: Declaration | Expression | undefined): DeclarationName | undefined; + function getDecorators(node: HasDecorators): readonly Decorator[] | undefined; + function getModifiers(node: HasModifiers): readonly Modifier[] | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -4482,6 +4504,7 @@ declare namespace ts { function isClassElement(node: Node): node is ClassElement; function isClassLike(node: Node): node is ClassLikeDeclaration; function isAccessor(node: Node): node is AccessorDeclaration; + function isModifierLike(node: Node): node is ModifierLike; function isTypeElement(node: Node): node is TypeElement; function isClassOrTypeElement(node: Node): node is ClassElement | TypeElement; function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike; @@ -4722,6 +4745,7 @@ declare namespace ts { function isImportClause(node: Node): node is ImportClause; function isAssertClause(node: Node): node is AssertClause; function isAssertEntry(node: Node): node is AssertEntry; + function isImportTypeAssertionContainer(node: Node): node is ImportTypeAssertionContainer; function isNamespaceImport(node: Node): node is NamespaceImport; function isNamespaceExport(node: Node): node is NamespaceExport; function isNamedImports(node: Node): node is NamedImports; @@ -10829,33 +10853,69 @@ declare namespace ts { (node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; }; /** @deprecated Use `factory.createParameterDeclaration` or the factory supplied by your transformation context instead. */ - const createParameter: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken | undefined, type?: TypeNode | undefined, initializer?: Expression | undefined) => ParameterDeclaration; + const createParameter: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken | undefined, type?: TypeNode | undefined, initializer?: Expression | undefined): ParameterDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken | undefined, type?: TypeNode | undefined, initializer?: Expression | undefined): ParameterDeclaration; + }; /** @deprecated Use `factory.updateParameterDeclaration` or the factory supplied by your transformation context instead. */ - const updateParameter: (node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) => ParameterDeclaration; + const updateParameter: { + (node: ParameterDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + (node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + }; /** @deprecated Use `factory.createDecorator` or the factory supplied by your transformation context instead. */ const createDecorator: (expression: Expression) => Decorator; /** @deprecated Use `factory.updateDecorator` or the factory supplied by your transformation context instead. */ const updateDecorator: (node: Decorator, expression: Expression) => Decorator; /** @deprecated Use `factory.createPropertyDeclaration` or the factory supplied by your transformation context instead. */ - const createProperty: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) => PropertyDeclaration; + const createProperty: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + }; /** @deprecated Use `factory.updatePropertyDeclaration` or the factory supplied by your transformation context instead. */ - const updateProperty: (node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) => PropertyDeclaration; + const updateProperty: { + (node: PropertyDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + (node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + }; /** @deprecated Use `factory.createMethodDeclaration` or the factory supplied by your transformation context instead. */ - const createMethod: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => MethodDeclaration; + const createMethod: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + }; /** @deprecated Use `factory.updateMethodDeclaration` or the factory supplied by your transformation context instead. */ - const updateMethod: (node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => MethodDeclaration; + const updateMethod: { + (node: MethodDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + (node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + }; /** @deprecated Use `factory.createConstructorDeclaration` or the factory supplied by your transformation context instead. */ - const createConstructor: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined) => ConstructorDeclaration; + const createConstructor: { + (decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + }; /** @deprecated Use `factory.updateConstructorDeclaration` or the factory supplied by your transformation context instead. */ - const updateConstructor: (node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined) => ConstructorDeclaration; + const updateConstructor: { + (node: ConstructorDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + (node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + }; /** @deprecated Use `factory.createGetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - const createGetAccessor: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => GetAccessorDeclaration; + const createGetAccessor: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + }; /** @deprecated Use `factory.updateGetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - const updateGetAccessor: (node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => GetAccessorDeclaration; + const updateGetAccessor: { + (node: GetAccessorDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + (node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + }; /** @deprecated Use `factory.createSetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - const createSetAccessor: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined) => SetAccessorDeclaration; + const createSetAccessor: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + }; /** @deprecated Use `factory.updateSetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - const updateSetAccessor: (node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined) => SetAccessorDeclaration; + const updateSetAccessor: { + (node: SetAccessorDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + (node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + }; /** @deprecated Use `factory.createCallSignature` or the factory supplied by your transformation context instead. */ const createCallSignature: (typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined) => CallSignatureDeclaration; /** @deprecated Use `factory.updateCallSignature` or the factory supplied by your transformation context instead. */ @@ -10865,7 +10925,10 @@ declare namespace ts { /** @deprecated Use `factory.updateConstructSignature` or the factory supplied by your transformation context instead. */ const updateConstructSignature: (node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) => ConstructSignatureDeclaration; /** @deprecated Use `factory.updateIndexSignature` or the factory supplied by your transformation context instead. */ - const updateIndexSignature: (node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode) => IndexSignatureDeclaration; + const updateIndexSignature: { + (node: IndexSignatureDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + (node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + }; /** @deprecated Use `factory.createKeywordTypeNode` or the factory supplied by your transformation context instead. */ const createKeywordTypeNode: (kind: TKind) => KeywordTypeNode; /** @deprecated Use `factory.createTypePredicateNode` or the factory supplied by your transformation context instead. */ @@ -10926,13 +10989,14 @@ declare namespace ts { const updateInferTypeNode: (node: InferTypeNode, typeParameter: TypeParameterDeclaration) => InferTypeNode; /** @deprecated Use `factory.createImportTypeNode` or the factory supplied by your transformation context instead. */ const createImportTypeNode: { - (argument: TypeNode, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; (argument: TypeNode, assertions?: ImportTypeAssertionContainer | undefined, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; + (argument: TypeNode, assertions?: ImportTypeAssertionContainer | undefined, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; + (argument: TypeNode, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; }; /** @deprecated Use `factory.updateImportTypeNode` or the factory supplied by your transformation context instead. */ const updateImportTypeNode: { - (node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; (node: ImportTypeNode, argument: TypeNode, assertions: ImportTypeAssertionContainer | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; + (node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; }; /** @deprecated Use `factory.createParenthesizedType` or the factory supplied by your transformation context instead. */ const createParenthesizedType: (type: TypeNode) => ParenthesizedTypeNode; @@ -11177,29 +11241,65 @@ declare namespace ts { /** @deprecated Use `factory.updateVariableDeclarationList` or the factory supplied by your transformation context instead. */ const updateVariableDeclarationList: (node: VariableDeclarationList, declarations: readonly VariableDeclaration[]) => VariableDeclarationList; /** @deprecated Use `factory.createFunctionDeclaration` or the factory supplied by your transformation context instead. */ - const createFunctionDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => FunctionDeclaration; + const createFunctionDeclaration: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + }; /** @deprecated Use `factory.updateFunctionDeclaration` or the factory supplied by your transformation context instead. */ - const updateFunctionDeclaration: (node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => FunctionDeclaration; + const updateFunctionDeclaration: { + (node: FunctionDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + (node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + }; /** @deprecated Use `factory.createClassDeclaration` or the factory supplied by your transformation context instead. */ - const createClassDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]) => ClassDeclaration; + const createClassDeclaration: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + }; /** @deprecated Use `factory.updateClassDeclaration` or the factory supplied by your transformation context instead. */ - const updateClassDeclaration: (node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]) => ClassDeclaration; + const updateClassDeclaration: { + (node: ClassDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + (node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + }; /** @deprecated Use `factory.createInterfaceDeclaration` or the factory supplied by your transformation context instead. */ - const createInterfaceDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]) => InterfaceDeclaration; + const createInterfaceDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + }; /** @deprecated Use `factory.updateInterfaceDeclaration` or the factory supplied by your transformation context instead. */ - const updateInterfaceDeclaration: (node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]) => InterfaceDeclaration; + const updateInterfaceDeclaration: { + (node: InterfaceDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + (node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + }; /** @deprecated Use `factory.createTypeAliasDeclaration` or the factory supplied by your transformation context instead. */ - const createTypeAliasDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode) => TypeAliasDeclaration; + const createTypeAliasDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + }; /** @deprecated Use `factory.updateTypeAliasDeclaration` or the factory supplied by your transformation context instead. */ - const updateTypeAliasDeclaration: (node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode) => TypeAliasDeclaration; + const updateTypeAliasDeclaration: { + (node: TypeAliasDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + (node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + }; /** @deprecated Use `factory.createEnumDeclaration` or the factory supplied by your transformation context instead. */ - const createEnumDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]) => EnumDeclaration; + const createEnumDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + }; /** @deprecated Use `factory.updateEnumDeclaration` or the factory supplied by your transformation context instead. */ - const updateEnumDeclaration: (node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]) => EnumDeclaration; + const updateEnumDeclaration: { + (node: EnumDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + (node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + }; /** @deprecated Use `factory.createModuleDeclaration` or the factory supplied by your transformation context instead. */ - const createModuleDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags | undefined) => ModuleDeclaration; + const createModuleDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags | undefined): ModuleDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags | undefined): ModuleDeclaration; + }; /** @deprecated Use `factory.updateModuleDeclaration` or the factory supplied by your transformation context instead. */ - const updateModuleDeclaration: (node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined) => ModuleDeclaration; + const updateModuleDeclaration: { + (node: ModuleDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + (node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + }; /** @deprecated Use `factory.createModuleBlock` or the factory supplied by your transformation context instead. */ const createModuleBlock: (statements: readonly Statement[]) => ModuleBlock; /** @deprecated Use `factory.updateModuleBlock` or the factory supplied by your transformation context instead. */ @@ -11213,13 +11313,25 @@ declare namespace ts { /** @deprecated Use `factory.updateNamespaceExportDeclaration` or the factory supplied by your transformation context instead. */ const updateNamespaceExportDeclaration: (node: NamespaceExportDeclaration, name: Identifier) => NamespaceExportDeclaration; /** @deprecated Use `factory.createImportEqualsDeclaration` or the factory supplied by your transformation context instead. */ - const createImportEqualsDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference) => ImportEqualsDeclaration; + const createImportEqualsDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + }; /** @deprecated Use `factory.updateImportEqualsDeclaration` or the factory supplied by your transformation context instead. */ - const updateImportEqualsDeclaration: (node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference) => ImportEqualsDeclaration; + const updateImportEqualsDeclaration: { + (node: ImportEqualsDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + (node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + }; /** @deprecated Use `factory.createImportDeclaration` or the factory supplied by your transformation context instead. */ - const createImportDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause | undefined) => ImportDeclaration; + const createImportDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause | undefined): ImportDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause | undefined): ImportDeclaration; + }; /** @deprecated Use `factory.updateImportDeclaration` or the factory supplied by your transformation context instead. */ - const updateImportDeclaration: (node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined) => ImportDeclaration; + const updateImportDeclaration: { + (node: ImportDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + (node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + }; /** @deprecated Use `factory.createNamespaceImport` or the factory supplied by your transformation context instead. */ const createNamespaceImport: (name: Identifier) => NamespaceImport; /** @deprecated Use `factory.updateNamespaceImport` or the factory supplied by your transformation context instead. */ @@ -11233,9 +11345,15 @@ declare namespace ts { /** @deprecated Use `factory.updateImportSpecifier` or the factory supplied by your transformation context instead. */ const updateImportSpecifier: (node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier) => ImportSpecifier; /** @deprecated Use `factory.createExportAssignment` or the factory supplied by your transformation context instead. */ - const createExportAssignment: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression) => ExportAssignment; + const createExportAssignment: { + (decorators: null, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + }; /** @deprecated Use `factory.updateExportAssignment` or the factory supplied by your transformation context instead. */ - const updateExportAssignment: (node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression) => ExportAssignment; + const updateExportAssignment: { + (node: ExportAssignment, decorators: null, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + (node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + }; /** @deprecated Use `factory.createNamedExports` or the factory supplied by your transformation context instead. */ const createNamedExports: (elements: readonly ExportSpecifier[]) => NamedExports; /** @deprecated Use `factory.updateNamedExports` or the factory supplied by your transformation context instead. */ @@ -11539,8 +11657,12 @@ declare namespace ts { * @deprecated Use an appropriate `factory.update...` method instead, use `setCommentRange` or `setSourceMapRange`, and avoid setting `parent`. */ const getMutableClone: (node: T) => T; +} +declare namespace ts { /** @deprecated Use `isTypeAssertionExpression` instead. */ const isTypeAssertion: (node: Node) => node is TypeAssertion; +} +declare namespace ts { /** * @deprecated Use `ts.ReadonlyESMap` instead. */ @@ -11551,11 +11673,294 @@ declare namespace ts { */ interface Map extends ESMap { } +} +declare namespace ts { /** * @deprecated Use `isMemberName` instead. */ const isIdentifierOrPrivateIdentifier: (node: Node) => node is MemberName; } +declare namespace ts { + interface NodeFactory { + /** @deprecated Use the overload that accepts 'modifiers' */ + createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; + /** @deprecated Use the overload that accepts 'modifiers' */ + updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): ConstructorTypeNode; + } +} +declare namespace ts { + interface NodeFactory { + createImportTypeNode(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + /** @deprecated Use the overload that accepts 'assertions' */ + createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + /** @deprecated Use the overload that accepts 'assertions' */ + updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode; + } +} +declare namespace ts { + interface NodeFactory { + /** @deprecated Use the overload that accepts 'modifiers' */ + createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; + /** @deprecated Use the overload that accepts 'modifiers' */ + updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; + } +} +declare namespace ts { + interface Node { + /** @deprecated `decorators` has been merged with `modifiers` on the declarations that support decorators. */ + readonly decorators?: readonly Decorator[] | undefined; + /** @deprecated `modifiers` has been removed from `Node` and moved to the specific `Node` subtypes that support them. */ + readonly modifiers?: NodeArray | undefined; + } + interface PropertySignature { + /** @deprecated A property signature cannot have an initializer */ + readonly initializer?: undefined; + } + interface PropertyAssignment { + /** @deprecated A property assignment cannot have a question token */ + readonly questionToken?: undefined; + /** @deprecated A property assignment cannot have an exclamation token */ + readonly exclamationToken?: undefined; + } + interface ShorthandPropertyAssignment { + /** @deprecated A shorthand property assignment cannot have a question token */ + readonly questionToken?: undefined; + /** @deprecated A shorthand property assignment cannot have an exclamation token */ + readonly exclamationToken?: undefined; + /** @deprecated A shorthand property assignment cannot have modifiers */ + readonly modifiers?: undefined; + } + interface NodeFactory { + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createPropertyDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updatePropertyDeclaration(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createMethodDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateMethodDeclaration(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createConstructorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateConstructorDeclaration(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createGetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateGetAccessorDeclaration(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createSetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateSetAccessorDeclaration(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createClassStaticBlockDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createClassExpression(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateClassExpression(node: ClassExpression, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause): ImportDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; + } +} export = ts; export as namespace ts; \ No newline at end of file diff --git a/tests/baselines/reference/api/typescript.d.ts b/tests/baselines/reference/api/typescript.d.ts index beb29fd613a93..71a7029402c03 100644 --- a/tests/baselines/reference/api/typescript.d.ts +++ b/tests/baselines/reference/api/typescript.d.ts @@ -554,13 +554,15 @@ declare namespace ts { Override = 16384, In = 32768, Out = 65536, + Decorator = 131072, HasComputedFlags = 536870912, AccessibilityModifier = 28, ParameterPropertyModifier = 16476, NonPublicAccessibilityModifier = 24, TypeScriptModifier = 116958, ExportDefault = 513, - All = 125951 + All = 257023, + Modifier = 125951 } export enum JsxFlags { None = 0, @@ -573,8 +575,6 @@ declare namespace ts { export interface Node extends ReadonlyTextRange { readonly kind: SyntaxKind; readonly flags: NodeFlags; - readonly decorators?: NodeArray; - readonly modifiers?: ModifiersArray; readonly parent: Node; } export interface JSDocContainer { @@ -583,7 +583,9 @@ declare namespace ts { export type HasType = SignatureDeclaration | VariableDeclaration | ParameterDeclaration | PropertySignature | PropertyDeclaration | TypePredicateNode | ParenthesizedTypeNode | TypeOperatorNode | MappedTypeNode | AssertionExpression | TypeAliasDeclaration | JSDocTypeExpression | JSDocNonNullableType | JSDocNullableType | JSDocOptionalType | JSDocVariadicType; export type HasTypeArguments = CallExpression | NewExpression | TaggedTemplateExpression | JsxOpeningElement | JsxSelfClosingElement; export type HasInitializer = HasExpressionInitializer | ForStatement | ForInStatement | ForOfStatement | JsxAttribute; - export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertySignature | PropertyDeclaration | PropertyAssignment | EnumMember; + export type HasExpressionInitializer = VariableDeclaration | ParameterDeclaration | BindingElement | PropertyDeclaration | PropertyAssignment | EnumMember; + export type HasDecorators = ParameterDeclaration | PropertyDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ClassExpression | ClassDeclaration; + export type HasModifiers = TypeParameterDeclaration | ParameterDeclaration | ConstructorTypeNode | PropertySignature | PropertyDeclaration | MethodSignature | MethodDeclaration | ConstructorDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | IndexSignatureDeclaration | FunctionExpression | ArrowFunction | ClassExpression | VariableStatement | FunctionDeclaration | ClassDeclaration | InterfaceDeclaration | TypeAliasDeclaration | EnumDeclaration | ModuleDeclaration | ImportEqualsDeclaration | ImportDeclaration | ExportAssignment | ExportDeclaration; export interface NodeArray extends ReadonlyArray, ReadonlyTextRange { readonly hasTrailingComma: boolean; } @@ -632,6 +634,7 @@ declare namespace ts { /** @deprecated Use `ReadonlyKeyword` instead. */ export type ReadonlyToken = ReadonlyKeyword; export type Modifier = AbstractKeyword | AsyncKeyword | ConstKeyword | DeclareKeyword | DefaultKeyword | ExportKeyword | InKeyword | PrivateKeyword | ProtectedKeyword | PublicKeyword | OutKeyword | OverrideKeyword | ReadonlyKeyword | StaticKeyword; + export type ModifierLike = Modifier | Decorator; export type AccessibilityModifier = PublicKeyword | PrivateKeyword | ProtectedKeyword; export type ParameterPropertyModifier = AccessibilityModifier | ReadonlyKeyword; export type ClassMemberModifier = AccessibilityModifier | ReadonlyKeyword | StaticKeyword; @@ -691,6 +694,7 @@ declare namespace ts { export interface TypeParameterDeclaration extends NamedDeclaration { readonly kind: SyntaxKind.TypeParameter; readonly parent: DeclarationWithTypeParameterChildren | InferTypeNode; + readonly modifiers?: NodeArray; readonly name: Identifier; /** Note: Consider calling `getEffectiveConstraintOfTypeParameter` */ readonly constraint?: TypeNode; @@ -700,9 +704,9 @@ declare namespace ts { export interface SignatureDeclarationBase extends NamedDeclaration, JSDocContainer { readonly kind: SignatureDeclaration["kind"]; readonly name?: PropertyName; - readonly typeParameters?: NodeArray; + readonly typeParameters?: NodeArray | undefined; readonly parameters: NodeArray; - readonly type?: TypeNode; + readonly type?: TypeNode | undefined; } export type SignatureDeclaration = CallSignatureDeclaration | ConstructSignatureDeclaration | MethodSignature | IndexSignatureDeclaration | FunctionTypeNode | ConstructorTypeNode | JSDocFunctionType | FunctionDeclaration | MethodDeclaration | ConstructorDeclaration | AccessorDeclaration | FunctionExpression | ArrowFunction; export interface CallSignatureDeclaration extends SignatureDeclarationBase, TypeElement { @@ -728,6 +732,7 @@ declare namespace ts { export interface ParameterDeclaration extends NamedDeclaration, JSDocContainer { readonly kind: SyntaxKind.Parameter; readonly parent: SignatureDeclaration; + readonly modifiers?: NodeArray; readonly dotDotDotToken?: DotDotDotToken; readonly name: BindingName; readonly questionToken?: QuestionToken; @@ -744,14 +749,15 @@ declare namespace ts { } export interface PropertySignature extends TypeElement, JSDocContainer { readonly kind: SyntaxKind.PropertySignature; + readonly modifiers?: NodeArray; readonly name: PropertyName; readonly questionToken?: QuestionToken; readonly type?: TypeNode; - initializer?: Expression; } export interface PropertyDeclaration extends ClassElement, JSDocContainer { readonly kind: SyntaxKind.PropertyDeclaration; readonly parent: ClassLikeDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; readonly questionToken?: QuestionToken; readonly exclamationToken?: ExclamationToken; @@ -768,16 +774,12 @@ declare namespace ts { readonly kind: SyntaxKind.PropertyAssignment; readonly parent: ObjectLiteralExpression; readonly name: PropertyName; - readonly questionToken?: QuestionToken; - readonly exclamationToken?: ExclamationToken; readonly initializer: Expression; } export interface ShorthandPropertyAssignment extends ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.ShorthandPropertyAssignment; readonly parent: ObjectLiteralExpression; readonly name: Identifier; - readonly questionToken?: QuestionToken; - readonly exclamationToken?: ExclamationToken; readonly equalsToken?: EqualsToken; readonly objectAssignmentInitializer?: Expression; } @@ -812,34 +814,41 @@ declare namespace ts { */ export interface FunctionLikeDeclarationBase extends SignatureDeclarationBase { _functionLikeDeclarationBrand: any; - readonly asteriskToken?: AsteriskToken; - readonly questionToken?: QuestionToken; - readonly exclamationToken?: ExclamationToken; - readonly body?: Block | Expression; + readonly asteriskToken?: AsteriskToken | undefined; + readonly questionToken?: QuestionToken | undefined; + readonly exclamationToken?: ExclamationToken | undefined; + readonly body?: Block | Expression | undefined; } export type FunctionLikeDeclaration = FunctionDeclaration | MethodDeclaration | GetAccessorDeclaration | SetAccessorDeclaration | ConstructorDeclaration | FunctionExpression | ArrowFunction; /** @deprecated Use SignatureDeclaration */ export type FunctionLike = SignatureDeclaration; export interface FunctionDeclaration extends FunctionLikeDeclarationBase, DeclarationStatement { readonly kind: SyntaxKind.FunctionDeclaration; + readonly modifiers?: NodeArray; readonly name?: Identifier; readonly body?: FunctionBody; } export interface MethodSignature extends SignatureDeclarationBase, TypeElement { readonly kind: SyntaxKind.MethodSignature; readonly parent: ObjectTypeDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; } export interface MethodDeclaration extends FunctionLikeDeclarationBase, ClassElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.MethodDeclaration; readonly parent: ClassLikeDeclaration | ObjectLiteralExpression; + readonly modifiers?: NodeArray | undefined; readonly name: PropertyName; - readonly body?: FunctionBody; + readonly exclamationToken?: undefined; + readonly body?: FunctionBody | undefined; } export interface ConstructorDeclaration extends FunctionLikeDeclarationBase, ClassElement, JSDocContainer { readonly kind: SyntaxKind.Constructor; readonly parent: ClassLikeDeclaration; - readonly body?: FunctionBody; + readonly modifiers?: NodeArray | undefined; + readonly body?: FunctionBody | undefined; + readonly typeParameters?: undefined; + readonly type?: undefined; } /** For when we encounter a semicolon in a class declaration. ES6 allows these as class elements. */ export interface SemicolonClassElement extends ClassElement { @@ -849,19 +858,25 @@ declare namespace ts { export interface GetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.GetAccessor; readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; + readonly typeParameters?: undefined; readonly body?: FunctionBody; } export interface SetAccessorDeclaration extends FunctionLikeDeclarationBase, ClassElement, TypeElement, ObjectLiteralElement, JSDocContainer { readonly kind: SyntaxKind.SetAccessor; readonly parent: ClassLikeDeclaration | ObjectLiteralExpression | TypeLiteralNode | InterfaceDeclaration; + readonly modifiers?: NodeArray; readonly name: PropertyName; + readonly typeParameters?: undefined; + readonly type?: undefined; readonly body?: FunctionBody; } export type AccessorDeclaration = GetAccessorDeclaration | SetAccessorDeclaration; export interface IndexSignatureDeclaration extends SignatureDeclarationBase, ClassElement, TypeElement { readonly kind: SyntaxKind.IndexSignature; readonly parent: ObjectTypeDeclaration; + readonly modifiers?: NodeArray; readonly type: TypeNode; } export interface ClassStaticBlockDeclaration extends ClassElement, JSDocContainer { @@ -898,9 +913,11 @@ declare namespace ts { } export interface FunctionTypeNode extends FunctionOrConstructorTypeNodeBase { readonly kind: SyntaxKind.FunctionType; + readonly modifiers?: undefined; } export interface ConstructorTypeNode extends FunctionOrConstructorTypeNodeBase { readonly kind: SyntaxKind.ConstructorType; + readonly modifiers?: NodeArray; } export interface NodeWithTypeArguments extends TypeNode { readonly typeArguments?: NodeArray; @@ -1157,11 +1174,13 @@ declare namespace ts { export type ConciseBody = FunctionBody | Expression; export interface FunctionExpression extends PrimaryExpression, FunctionLikeDeclarationBase, JSDocContainer { readonly kind: SyntaxKind.FunctionExpression; + readonly modifiers?: NodeArray; readonly name?: Identifier; readonly body: FunctionBody; } export interface ArrowFunction extends Expression, FunctionLikeDeclarationBase, JSDocContainer { readonly kind: SyntaxKind.ArrowFunction; + readonly modifiers?: NodeArray; readonly equalsGreaterThanToken: EqualsGreaterThanToken; readonly body: ConciseBody; readonly name: never; @@ -1442,6 +1461,7 @@ declare namespace ts { } export interface VariableStatement extends Statement { readonly kind: SyntaxKind.VariableStatement; + readonly modifiers?: NodeArray; readonly declarationList: VariableDeclarationList; } export interface ExpressionStatement extends Statement { @@ -1558,11 +1578,13 @@ declare namespace ts { } export interface ClassDeclaration extends ClassLikeDeclarationBase, DeclarationStatement { readonly kind: SyntaxKind.ClassDeclaration; + readonly modifiers?: NodeArray; /** May be undefined in `export default class { ... }`. */ readonly name?: Identifier; } export interface ClassExpression extends ClassLikeDeclarationBase, PrimaryExpression { readonly kind: SyntaxKind.ClassExpression; + readonly modifiers?: NodeArray; } export type ClassLikeDeclaration = ClassDeclaration | ClassExpression; export interface ClassElement extends NamedDeclaration { @@ -1572,10 +1594,11 @@ declare namespace ts { export interface TypeElement extends NamedDeclaration { _typeElementBrand: any; readonly name?: PropertyName; - readonly questionToken?: QuestionToken; + readonly questionToken?: QuestionToken | undefined; } export interface InterfaceDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.InterfaceDeclaration; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly typeParameters?: NodeArray; readonly heritageClauses?: NodeArray; @@ -1589,6 +1612,7 @@ declare namespace ts { } export interface TypeAliasDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.TypeAliasDeclaration; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly typeParameters?: NodeArray; readonly type: TypeNode; @@ -1601,6 +1625,7 @@ declare namespace ts { } export interface EnumDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.EnumDeclaration; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly members: NodeArray; } @@ -1609,6 +1634,7 @@ declare namespace ts { export interface ModuleDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ModuleDeclaration; readonly parent: ModuleBody | SourceFile; + readonly modifiers?: NodeArray; readonly name: ModuleName; readonly body?: ModuleBody | JSDocNamespaceDeclaration; } @@ -1636,6 +1662,7 @@ declare namespace ts { export interface ImportEqualsDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ImportEqualsDeclaration; readonly parent: SourceFile | ModuleBlock; + readonly modifiers?: NodeArray; readonly name: Identifier; readonly isTypeOnly: boolean; readonly moduleReference: ModuleReference; @@ -1648,6 +1675,7 @@ declare namespace ts { export interface ImportDeclaration extends Statement { readonly kind: SyntaxKind.ImportDeclaration; readonly parent: SourceFile | ModuleBlock; + readonly modifiers?: NodeArray; readonly importClause?: ImportClause; /** If this is not a StringLiteral it will be a grammar error. */ readonly moduleSpecifier: Expression; @@ -1692,6 +1720,7 @@ declare namespace ts { export interface ExportDeclaration extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ExportDeclaration; readonly parent: SourceFile | ModuleBlock; + readonly modifiers?: NodeArray; readonly isTypeOnly: boolean; /** Will not be assigned in the case of `export * from "foo";` */ readonly exportClause?: NamedExportBindings; @@ -1759,6 +1788,7 @@ declare namespace ts { export interface ExportAssignment extends DeclarationStatement, JSDocContainer { readonly kind: SyntaxKind.ExportAssignment; readonly parent: SourceFile; + readonly modifiers?: NodeArray; readonly isExportEquals?: boolean; readonly expression: Expression; } @@ -3402,39 +3432,35 @@ declare namespace ts { createComputedPropertyName(expression: Expression): ComputedPropertyName; updateComputedPropertyName(node: ComputedPropertyName, expression: Expression): ComputedPropertyName; createTypeParameterDeclaration(modifiers: readonly Modifier[] | undefined, name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; - /** @deprecated */ - createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; updateTypeParameterDeclaration(node: TypeParameterDeclaration, modifiers: readonly Modifier[] | undefined, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - /** @deprecated */ - updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; - createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; - updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + createParameterDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + updateParameterDeclaration(node: ParameterDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; createDecorator(expression: Expression): Decorator; updateDecorator(node: Decorator, expression: Expression): Decorator; createPropertySignature(modifiers: readonly Modifier[] | undefined, name: PropertyName | string, questionToken: QuestionToken | undefined, type: TypeNode | undefined): PropertySignature; updatePropertySignature(node: PropertySignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, type: TypeNode | undefined): PropertySignature; - createPropertyDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; - updatePropertyDeclaration(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + createPropertyDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + updatePropertyDeclaration(node: PropertyDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; createMethodSignature(modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): MethodSignature; updateMethodSignature(node: MethodSignature, modifiers: readonly Modifier[] | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): MethodSignature; - createMethodDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - updateMethodDeclaration(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; - createConstructorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; - updateConstructorDeclaration(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; - createGetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - updateGetAccessorDeclaration(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; - createSetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; - updateSetAccessorDeclaration(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + createMethodDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + updateMethodDeclaration(node: MethodDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + createConstructorDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + updateConstructorDeclaration(node: ConstructorDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + createGetAccessorDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + updateGetAccessorDeclaration(node: GetAccessorDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + createSetAccessorDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + updateSetAccessorDeclaration(node: SetAccessorDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; createCallSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): CallSignatureDeclaration; updateCallSignature(node: CallSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): CallSignatureDeclaration; createConstructSignature(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined): ConstructSignatureDeclaration; updateConstructSignature(node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined): ConstructSignatureDeclaration; - createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; - updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + createIndexSignature(decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + updateIndexSignature(node: IndexSignatureDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; createTemplateLiteralTypeSpan(type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan; updateTemplateLiteralTypeSpan(node: TemplateLiteralTypeSpan, type: TypeNode, literal: TemplateMiddle | TemplateTail): TemplateLiteralTypeSpan; - createClassStaticBlockDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; - updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; + createClassStaticBlockDeclaration(decorators: null, modifiers: null, body: Block): ClassStaticBlockDeclaration; + updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: null, modifiers: null, body: Block): ClassStaticBlockDeclaration; createKeywordTypeNode(kind: TKind): KeywordTypeNode; createTypePredicateNode(assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode | string, type: TypeNode | undefined): TypePredicateNode; updateTypePredicateNode(node: TypePredicateNode, assertsModifier: AssertsKeyword | undefined, parameterName: Identifier | ThisTypeNode, type: TypeNode | undefined): TypePredicateNode; @@ -3443,11 +3469,7 @@ declare namespace ts { createFunctionTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): FunctionTypeNode; updateFunctionTypeNode(node: FunctionTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): FunctionTypeNode; createConstructorTypeNode(modifiers: readonly Modifier[] | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; - /** @deprecated */ - createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; updateConstructorTypeNode(node: ConstructorTypeNode, modifiers: readonly Modifier[] | undefined, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): ConstructorTypeNode; - /** @deprecated */ - updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): ConstructorTypeNode; createTypeQueryNode(exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode; updateTypeQueryNode(node: TypeQueryNode, exprName: EntityName, typeArguments?: readonly TypeNode[]): TypeQueryNode; createTypeLiteralNode(members: readonly TypeElement[] | undefined): TypeLiteralNode; @@ -3470,9 +3492,7 @@ declare namespace ts { updateConditionalTypeNode(node: ConditionalTypeNode, checkType: TypeNode, extendsType: TypeNode, trueType: TypeNode, falseType: TypeNode): ConditionalTypeNode; createInferTypeNode(typeParameter: TypeParameterDeclaration): InferTypeNode; updateInferTypeNode(node: InferTypeNode, typeParameter: TypeParameterDeclaration): InferTypeNode; - createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; createImportTypeNode(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; - updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode; updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, assertions: ImportTypeAssertionContainer | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode; createParenthesizedType(type: TypeNode): ParenthesizedTypeNode; updateParenthesizedType(node: ParenthesizedTypeNode, type: TypeNode): ParenthesizedTypeNode; @@ -3552,8 +3572,8 @@ declare namespace ts { updateYieldExpression(node: YieldExpression, asteriskToken: AsteriskToken | undefined, expression: Expression | undefined): YieldExpression; createSpreadElement(expression: Expression): SpreadElement; updateSpreadElement(node: SpreadElement, expression: Expression): SpreadElement; - createClassExpression(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; - updateClassExpression(node: ClassExpression, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + createClassExpression(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + updateClassExpression(node: ClassExpression, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; createOmittedExpression(): OmittedExpression; createExpressionWithTypeArguments(expression: Expression, typeArguments: readonly TypeNode[] | undefined): ExpressionWithTypeArguments; updateExpressionWithTypeArguments(node: ExpressionWithTypeArguments, expression: Expression, typeArguments: readonly TypeNode[] | undefined): ExpressionWithTypeArguments; @@ -3608,28 +3628,28 @@ declare namespace ts { updateVariableDeclaration(node: VariableDeclaration, name: BindingName, exclamationToken: ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): VariableDeclaration; createVariableDeclarationList(declarations: readonly VariableDeclaration[], flags?: NodeFlags): VariableDeclarationList; updateVariableDeclarationList(node: VariableDeclarationList, declarations: readonly VariableDeclaration[]): VariableDeclarationList; - createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; - createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; - updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; - createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; - updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; - createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; - updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; - createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; - updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; - createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; - updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + createFunctionDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + updateFunctionDeclaration(node: FunctionDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + createClassDeclaration(decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + updateClassDeclaration(node: ClassDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + createInterfaceDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + createTypeAliasDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + createEnumDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + updateEnumDeclaration(node: EnumDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + createModuleDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + updateModuleDeclaration(node: ModuleDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; createModuleBlock(statements: readonly Statement[]): ModuleBlock; updateModuleBlock(node: ModuleBlock, statements: readonly Statement[]): ModuleBlock; createCaseBlock(clauses: readonly CaseOrDefaultClause[]): CaseBlock; updateCaseBlock(node: CaseBlock, clauses: readonly CaseOrDefaultClause[]): CaseBlock; createNamespaceExportDeclaration(name: string | Identifier): NamespaceExportDeclaration; updateNamespaceExportDeclaration(node: NamespaceExportDeclaration, name: Identifier): NamespaceExportDeclaration; - createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; - createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause): ImportDeclaration; - updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + createImportEqualsDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + createImportDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause): ImportDeclaration; + updateImportDeclaration(node: ImportDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; createImportClause(isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; updateImportClause(node: ImportClause, isTypeOnly: boolean, name: Identifier | undefined, namedBindings: NamedImportBindings | undefined): ImportClause; createAssertClause(elements: NodeArray, multiLine?: boolean): AssertClause; @@ -3646,10 +3666,10 @@ declare namespace ts { updateNamedImports(node: NamedImports, elements: readonly ImportSpecifier[]): NamedImports; createImportSpecifier(isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; updateImportSpecifier(node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier): ImportSpecifier; - createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; - updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; - createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; - updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; + createExportAssignment(decorators: null, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + updateExportAssignment(node: ExportAssignment, decorators: null, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + createExportDeclaration(decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; + updateExportDeclaration(node: ExportDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; createNamedExports(elements: readonly ExportSpecifier[]): NamedExports; updateNamedExports(node: NamedExports, elements: readonly ExportSpecifier[]): NamedExports; createExportSpecifier(isTypeOnly: boolean, propertyName: string | Identifier | undefined, name: string | Identifier): ExportSpecifier; @@ -4055,7 +4075,7 @@ declare namespace ts { NoSpaceIfEmpty = 524288, SingleElement = 1048576, SpaceAfterList = 2097152, - Modifiers = 262656, + Modifiers = 2359808, HeritageClauses = 512, SingleLineTypeLiteralMembers = 768, MultiLineTypeLiteralMembers = 32897, @@ -4349,6 +4369,8 @@ declare namespace ts { function symbolName(symbol: Symbol): string; function getNameOfJSDocTypedef(declaration: JSDocTypedefTag): Identifier | PrivateIdentifier | undefined; function getNameOfDeclaration(declaration: Declaration | Expression | undefined): DeclarationName | undefined; + function getDecorators(node: HasDecorators): readonly Decorator[] | undefined; + function getModifiers(node: HasModifiers): readonly Modifier[] | undefined; /** * Gets the JSDoc parameter tags for the node if present. * @@ -4482,6 +4504,7 @@ declare namespace ts { function isClassElement(node: Node): node is ClassElement; function isClassLike(node: Node): node is ClassLikeDeclaration; function isAccessor(node: Node): node is AccessorDeclaration; + function isModifierLike(node: Node): node is ModifierLike; function isTypeElement(node: Node): node is TypeElement; function isClassOrTypeElement(node: Node): node is ClassElement | TypeElement; function isObjectLiteralElementLike(node: Node): node is ObjectLiteralElementLike; @@ -4722,6 +4745,7 @@ declare namespace ts { function isImportClause(node: Node): node is ImportClause; function isAssertClause(node: Node): node is AssertClause; function isAssertEntry(node: Node): node is AssertEntry; + function isImportTypeAssertionContainer(node: Node): node is ImportTypeAssertionContainer; function isNamespaceImport(node: Node): node is NamespaceImport; function isNamespaceExport(node: Node): node is NamespaceExport; function isNamedImports(node: Node): node is NamedImports; @@ -6972,33 +6996,69 @@ declare namespace ts { (node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; }; /** @deprecated Use `factory.createParameterDeclaration` or the factory supplied by your transformation context instead. */ - const createParameter: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken | undefined, type?: TypeNode | undefined, initializer?: Expression | undefined) => ParameterDeclaration; + const createParameter: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken | undefined, type?: TypeNode | undefined, initializer?: Expression | undefined): ParameterDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken | undefined, type?: TypeNode | undefined, initializer?: Expression | undefined): ParameterDeclaration; + }; /** @deprecated Use `factory.updateParameterDeclaration` or the factory supplied by your transformation context instead. */ - const updateParameter: (node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) => ParameterDeclaration; + const updateParameter: { + (node: ParameterDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + (node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + }; /** @deprecated Use `factory.createDecorator` or the factory supplied by your transformation context instead. */ const createDecorator: (expression: Expression) => Decorator; /** @deprecated Use `factory.updateDecorator` or the factory supplied by your transformation context instead. */ const updateDecorator: (node: Decorator, expression: Expression) => Decorator; /** @deprecated Use `factory.createPropertyDeclaration` or the factory supplied by your transformation context instead. */ - const createProperty: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) => PropertyDeclaration; + const createProperty: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + }; /** @deprecated Use `factory.updatePropertyDeclaration` or the factory supplied by your transformation context instead. */ - const updateProperty: (node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined) => PropertyDeclaration; + const updateProperty: { + (node: PropertyDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + (node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + }; /** @deprecated Use `factory.createMethodDeclaration` or the factory supplied by your transformation context instead. */ - const createMethod: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => MethodDeclaration; + const createMethod: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + }; /** @deprecated Use `factory.updateMethodDeclaration` or the factory supplied by your transformation context instead. */ - const updateMethod: (node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => MethodDeclaration; + const updateMethod: { + (node: MethodDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + (node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + }; /** @deprecated Use `factory.createConstructorDeclaration` or the factory supplied by your transformation context instead. */ - const createConstructor: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined) => ConstructorDeclaration; + const createConstructor: { + (decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + }; /** @deprecated Use `factory.updateConstructorDeclaration` or the factory supplied by your transformation context instead. */ - const updateConstructor: (node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined) => ConstructorDeclaration; + const updateConstructor: { + (node: ConstructorDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + (node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + }; /** @deprecated Use `factory.createGetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - const createGetAccessor: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => GetAccessorDeclaration; + const createGetAccessor: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + }; /** @deprecated Use `factory.updateGetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - const updateGetAccessor: (node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => GetAccessorDeclaration; + const updateGetAccessor: { + (node: GetAccessorDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + (node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + }; /** @deprecated Use `factory.createSetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - const createSetAccessor: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined) => SetAccessorDeclaration; + const createSetAccessor: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + }; /** @deprecated Use `factory.updateSetAccessorDeclaration` or the factory supplied by your transformation context instead. */ - const updateSetAccessor: (node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined) => SetAccessorDeclaration; + const updateSetAccessor: { + (node: SetAccessorDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + (node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + }; /** @deprecated Use `factory.createCallSignature` or the factory supplied by your transformation context instead. */ const createCallSignature: (typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined) => CallSignatureDeclaration; /** @deprecated Use `factory.updateCallSignature` or the factory supplied by your transformation context instead. */ @@ -7008,7 +7068,10 @@ declare namespace ts { /** @deprecated Use `factory.updateConstructSignature` or the factory supplied by your transformation context instead. */ const updateConstructSignature: (node: ConstructSignatureDeclaration, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode | undefined) => ConstructSignatureDeclaration; /** @deprecated Use `factory.updateIndexSignature` or the factory supplied by your transformation context instead. */ - const updateIndexSignature: (node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode) => IndexSignatureDeclaration; + const updateIndexSignature: { + (node: IndexSignatureDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + (node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + }; /** @deprecated Use `factory.createKeywordTypeNode` or the factory supplied by your transformation context instead. */ const createKeywordTypeNode: (kind: TKind) => KeywordTypeNode; /** @deprecated Use `factory.createTypePredicateNode` or the factory supplied by your transformation context instead. */ @@ -7069,13 +7132,14 @@ declare namespace ts { const updateInferTypeNode: (node: InferTypeNode, typeParameter: TypeParameterDeclaration) => InferTypeNode; /** @deprecated Use `factory.createImportTypeNode` or the factory supplied by your transformation context instead. */ const createImportTypeNode: { - (argument: TypeNode, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; (argument: TypeNode, assertions?: ImportTypeAssertionContainer | undefined, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; + (argument: TypeNode, assertions?: ImportTypeAssertionContainer | undefined, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; + (argument: TypeNode, qualifier?: EntityName | undefined, typeArguments?: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; }; /** @deprecated Use `factory.updateImportTypeNode` or the factory supplied by your transformation context instead. */ const updateImportTypeNode: { - (node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; (node: ImportTypeNode, argument: TypeNode, assertions: ImportTypeAssertionContainer | undefined, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; + (node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean | undefined): ImportTypeNode; }; /** @deprecated Use `factory.createParenthesizedType` or the factory supplied by your transformation context instead. */ const createParenthesizedType: (type: TypeNode) => ParenthesizedTypeNode; @@ -7320,29 +7384,65 @@ declare namespace ts { /** @deprecated Use `factory.updateVariableDeclarationList` or the factory supplied by your transformation context instead. */ const updateVariableDeclarationList: (node: VariableDeclarationList, declarations: readonly VariableDeclaration[]) => VariableDeclarationList; /** @deprecated Use `factory.createFunctionDeclaration` or the factory supplied by your transformation context instead. */ - const createFunctionDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => FunctionDeclaration; + const createFunctionDeclaration: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + }; /** @deprecated Use `factory.updateFunctionDeclaration` or the factory supplied by your transformation context instead. */ - const updateFunctionDeclaration: (node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined) => FunctionDeclaration; + const updateFunctionDeclaration: { + (node: FunctionDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + (node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + }; /** @deprecated Use `factory.createClassDeclaration` or the factory supplied by your transformation context instead. */ - const createClassDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]) => ClassDeclaration; + const createClassDeclaration: { + (decorators: null, modifiers: readonly ModifierLike[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + }; /** @deprecated Use `factory.updateClassDeclaration` or the factory supplied by your transformation context instead. */ - const updateClassDeclaration: (node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]) => ClassDeclaration; + const updateClassDeclaration: { + (node: ClassDeclaration, decorators: null, modifiers: readonly ModifierLike[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + (node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + }; /** @deprecated Use `factory.createInterfaceDeclaration` or the factory supplied by your transformation context instead. */ - const createInterfaceDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]) => InterfaceDeclaration; + const createInterfaceDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + }; /** @deprecated Use `factory.updateInterfaceDeclaration` or the factory supplied by your transformation context instead. */ - const updateInterfaceDeclaration: (node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]) => InterfaceDeclaration; + const updateInterfaceDeclaration: { + (node: InterfaceDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + (node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + }; /** @deprecated Use `factory.createTypeAliasDeclaration` or the factory supplied by your transformation context instead. */ - const createTypeAliasDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode) => TypeAliasDeclaration; + const createTypeAliasDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + }; /** @deprecated Use `factory.updateTypeAliasDeclaration` or the factory supplied by your transformation context instead. */ - const updateTypeAliasDeclaration: (node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode) => TypeAliasDeclaration; + const updateTypeAliasDeclaration: { + (node: TypeAliasDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + (node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + }; /** @deprecated Use `factory.createEnumDeclaration` or the factory supplied by your transformation context instead. */ - const createEnumDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]) => EnumDeclaration; + const createEnumDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + }; /** @deprecated Use `factory.updateEnumDeclaration` or the factory supplied by your transformation context instead. */ - const updateEnumDeclaration: (node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]) => EnumDeclaration; + const updateEnumDeclaration: { + (node: EnumDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + (node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + }; /** @deprecated Use `factory.createModuleDeclaration` or the factory supplied by your transformation context instead. */ - const createModuleDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags | undefined) => ModuleDeclaration; + const createModuleDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags | undefined): ModuleDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags | undefined): ModuleDeclaration; + }; /** @deprecated Use `factory.updateModuleDeclaration` or the factory supplied by your transformation context instead. */ - const updateModuleDeclaration: (node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined) => ModuleDeclaration; + const updateModuleDeclaration: { + (node: ModuleDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + (node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + }; /** @deprecated Use `factory.createModuleBlock` or the factory supplied by your transformation context instead. */ const createModuleBlock: (statements: readonly Statement[]) => ModuleBlock; /** @deprecated Use `factory.updateModuleBlock` or the factory supplied by your transformation context instead. */ @@ -7356,13 +7456,25 @@ declare namespace ts { /** @deprecated Use `factory.updateNamespaceExportDeclaration` or the factory supplied by your transformation context instead. */ const updateNamespaceExportDeclaration: (node: NamespaceExportDeclaration, name: Identifier) => NamespaceExportDeclaration; /** @deprecated Use `factory.createImportEqualsDeclaration` or the factory supplied by your transformation context instead. */ - const createImportEqualsDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference) => ImportEqualsDeclaration; + const createImportEqualsDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + }; /** @deprecated Use `factory.updateImportEqualsDeclaration` or the factory supplied by your transformation context instead. */ - const updateImportEqualsDeclaration: (node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference) => ImportEqualsDeclaration; + const updateImportEqualsDeclaration: { + (node: ImportEqualsDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + (node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + }; /** @deprecated Use `factory.createImportDeclaration` or the factory supplied by your transformation context instead. */ - const createImportDeclaration: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause | undefined) => ImportDeclaration; + const createImportDeclaration: { + (decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause | undefined): ImportDeclaration; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause | undefined): ImportDeclaration; + }; /** @deprecated Use `factory.updateImportDeclaration` or the factory supplied by your transformation context instead. */ - const updateImportDeclaration: (node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined) => ImportDeclaration; + const updateImportDeclaration: { + (node: ImportDeclaration, decorators: null, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + (node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + }; /** @deprecated Use `factory.createNamespaceImport` or the factory supplied by your transformation context instead. */ const createNamespaceImport: (name: Identifier) => NamespaceImport; /** @deprecated Use `factory.updateNamespaceImport` or the factory supplied by your transformation context instead. */ @@ -7376,9 +7488,15 @@ declare namespace ts { /** @deprecated Use `factory.updateImportSpecifier` or the factory supplied by your transformation context instead. */ const updateImportSpecifier: (node: ImportSpecifier, isTypeOnly: boolean, propertyName: Identifier | undefined, name: Identifier) => ImportSpecifier; /** @deprecated Use `factory.createExportAssignment` or the factory supplied by your transformation context instead. */ - const createExportAssignment: (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression) => ExportAssignment; + const createExportAssignment: { + (decorators: null, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + (decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + }; /** @deprecated Use `factory.updateExportAssignment` or the factory supplied by your transformation context instead. */ - const updateExportAssignment: (node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression) => ExportAssignment; + const updateExportAssignment: { + (node: ExportAssignment, decorators: null, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + (node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + }; /** @deprecated Use `factory.createNamedExports` or the factory supplied by your transformation context instead. */ const createNamedExports: (elements: readonly ExportSpecifier[]) => NamedExports; /** @deprecated Use `factory.updateNamedExports` or the factory supplied by your transformation context instead. */ @@ -7682,8 +7800,12 @@ declare namespace ts { * @deprecated Use an appropriate `factory.update...` method instead, use `setCommentRange` or `setSourceMapRange`, and avoid setting `parent`. */ const getMutableClone: (node: T) => T; +} +declare namespace ts { /** @deprecated Use `isTypeAssertionExpression` instead. */ const isTypeAssertion: (node: Node) => node is TypeAssertion; +} +declare namespace ts { /** * @deprecated Use `ts.ReadonlyESMap` instead. */ @@ -7694,10 +7816,293 @@ declare namespace ts { */ interface Map extends ESMap { } +} +declare namespace ts { /** * @deprecated Use `isMemberName` instead. */ const isIdentifierOrPrivateIdentifier: (node: Node) => node is MemberName; } +declare namespace ts { + interface NodeFactory { + /** @deprecated Use the overload that accepts 'modifiers' */ + createConstructorTypeNode(typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): ConstructorTypeNode; + /** @deprecated Use the overload that accepts 'modifiers' */ + updateConstructorTypeNode(node: ConstructorTypeNode, typeParameters: NodeArray | undefined, parameters: NodeArray, type: TypeNode): ConstructorTypeNode; + } +} +declare namespace ts { + interface NodeFactory { + createImportTypeNode(argument: TypeNode, assertions?: ImportTypeAssertionContainer, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + /** @deprecated Use the overload that accepts 'assertions' */ + createImportTypeNode(argument: TypeNode, qualifier?: EntityName, typeArguments?: readonly TypeNode[], isTypeOf?: boolean): ImportTypeNode; + /** @deprecated Use the overload that accepts 'assertions' */ + updateImportTypeNode(node: ImportTypeNode, argument: TypeNode, qualifier: EntityName | undefined, typeArguments: readonly TypeNode[] | undefined, isTypeOf?: boolean): ImportTypeNode; + } +} +declare namespace ts { + interface NodeFactory { + /** @deprecated Use the overload that accepts 'modifiers' */ + createTypeParameterDeclaration(name: string | Identifier, constraint?: TypeNode, defaultType?: TypeNode): TypeParameterDeclaration; + /** @deprecated Use the overload that accepts 'modifiers' */ + updateTypeParameterDeclaration(node: TypeParameterDeclaration, name: Identifier, constraint: TypeNode | undefined, defaultType: TypeNode | undefined): TypeParameterDeclaration; + } +} +declare namespace ts { + interface Node { + /** @deprecated `decorators` has been merged with `modifiers` on the declarations that support decorators. */ + readonly decorators?: readonly Decorator[] | undefined; + /** @deprecated `modifiers` has been removed from `Node` and moved to the specific `Node` subtypes that support them. */ + readonly modifiers?: NodeArray | undefined; + } + interface PropertySignature { + /** @deprecated A property signature cannot have an initializer */ + readonly initializer?: undefined; + } + interface PropertyAssignment { + /** @deprecated A property assignment cannot have a question token */ + readonly questionToken?: undefined; + /** @deprecated A property assignment cannot have an exclamation token */ + readonly exclamationToken?: undefined; + } + interface ShorthandPropertyAssignment { + /** @deprecated A shorthand property assignment cannot have a question token */ + readonly questionToken?: undefined; + /** @deprecated A shorthand property assignment cannot have an exclamation token */ + readonly exclamationToken?: undefined; + /** @deprecated A shorthand property assignment cannot have modifiers */ + readonly modifiers?: undefined; + } + interface NodeFactory { + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createParameterDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken?: QuestionToken, type?: TypeNode, initializer?: Expression): ParameterDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateParameterDeclaration(node: ParameterDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, dotDotDotToken: DotDotDotToken | undefined, name: string | BindingName, questionToken: QuestionToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): ParameterDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createPropertyDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updatePropertyDeclaration(node: PropertyDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, questionOrExclamationToken: QuestionToken | ExclamationToken | undefined, type: TypeNode | undefined, initializer: Expression | undefined): PropertyDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createMethodDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateMethodDeclaration(node: MethodDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: PropertyName, questionToken: QuestionToken | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): MethodDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createConstructorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateConstructorDeclaration(node: ConstructorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], body: Block | undefined): ConstructorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createGetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateGetAccessorDeclaration(node: GetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): GetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createSetAccessorDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateSetAccessorDeclaration(node: SetAccessorDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: PropertyName, parameters: readonly ParameterDeclaration[], body: Block | undefined): SetAccessorDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createIndexSignature(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateIndexSignature(node: IndexSignatureDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode): IndexSignatureDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createClassStaticBlockDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateClassStaticBlockDeclaration(node: ClassStaticBlockDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, body: Block): ClassStaticBlockDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createClassExpression(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateClassExpression(node: ClassExpression, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassExpression; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createFunctionDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateFunctionDeclaration(node: FunctionDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, asteriskToken: AsteriskToken | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, parameters: readonly ParameterDeclaration[], type: TypeNode | undefined, body: Block | undefined): FunctionDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createClassDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateClassDeclaration(node: ClassDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier | undefined, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly ClassElement[]): ClassDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createInterfaceDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateInterfaceDeclaration(node: InterfaceDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, heritageClauses: readonly HeritageClause[] | undefined, members: readonly TypeElement[]): InterfaceDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createTypeAliasDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateTypeAliasDeclaration(node: TypeAliasDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, typeParameters: readonly TypeParameterDeclaration[] | undefined, type: TypeNode): TypeAliasDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createEnumDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: string | Identifier, members: readonly EnumMember[]): EnumDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateEnumDeclaration(node: EnumDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: Identifier, members: readonly EnumMember[]): EnumDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createModuleDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined, flags?: NodeFlags): ModuleDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateModuleDeclaration(node: ModuleDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, name: ModuleName, body: ModuleBody | undefined): ModuleDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createImportEqualsDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: string | Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateImportEqualsDeclaration(node: ImportEqualsDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, name: Identifier, moduleReference: ModuleReference): ImportEqualsDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createImportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause?: AssertClause): ImportDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateImportDeclaration(node: ImportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, importClause: ImportClause | undefined, moduleSpecifier: Expression, assertClause: AssertClause | undefined): ImportDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createExportAssignment(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isExportEquals: boolean | undefined, expression: Expression): ExportAssignment; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateExportAssignment(node: ExportAssignment, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, expression: Expression): ExportAssignment; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + createExportDeclaration(decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier?: Expression, assertClause?: AssertClause): ExportDeclaration; + /** + * @deprecated Decorators have been combined with modifiers. Callers should pass + * `null` to the `decorators` parameter so that a future update can introduce + * an overload that removes the parameter entirely. + */ + updateExportDeclaration(node: ExportDeclaration, decorators: readonly Decorator[] | undefined, modifiers: readonly Modifier[] | undefined, isTypeOnly: boolean, exportClause: NamedExportBindings | undefined, moduleSpecifier: Expression | undefined, assertClause: AssertClause | undefined): ExportDeclaration; + } +} export = ts; \ No newline at end of file diff --git a/tests/baselines/reference/errorOnInitializerInInterfaceProperty.types b/tests/baselines/reference/errorOnInitializerInInterfaceProperty.types index b3ab747f34c9e..f2abaa0bf3d08 100644 --- a/tests/baselines/reference/errorOnInitializerInInterfaceProperty.types +++ b/tests/baselines/reference/errorOnInitializerInInterfaceProperty.types @@ -2,6 +2,5 @@ interface Foo { bar: number = 5; >bar : number ->5 : 5 } diff --git a/tests/baselines/reference/errorOnInitializerInObjectTypeLiteralProperty.types b/tests/baselines/reference/errorOnInitializerInObjectTypeLiteralProperty.types index 9e62f5d6bc0e6..d7154b3099a29 100644 --- a/tests/baselines/reference/errorOnInitializerInObjectTypeLiteralProperty.types +++ b/tests/baselines/reference/errorOnInitializerInObjectTypeLiteralProperty.types @@ -4,7 +4,6 @@ var Foo: { bar: number = 5; >bar : number ->5 : 5 }; @@ -13,7 +12,6 @@ let Bar: { bar: number = 5; >bar : number ->5 : 5 }; diff --git a/tests/baselines/reference/parserConstructorDeclaration11.errors.txt b/tests/baselines/reference/parserConstructorDeclaration11.errors.txt index e8a799fc36a61..5ffeaf94ea925 100644 --- a/tests/baselines/reference/parserConstructorDeclaration11.errors.txt +++ b/tests/baselines/reference/parserConstructorDeclaration11.errors.txt @@ -1,12 +1,9 @@ -tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts(2,14): error TS1098: Type parameter list cannot be empty. tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts(2,15): error TS1092: Type parameters cannot appear on a constructor declaration. -==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts (2 errors) ==== +==== tests/cases/conformance/parser/ecmascript5/ConstructorDeclarations/parserConstructorDeclaration11.ts (1 errors) ==== class C { constructor<>() { } - ~~ -!!! error TS1098: Type parameter list cannot be empty. !!! error TS1092: Type parameters cannot appear on a constructor declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/parserConstructorDeclaration12.errors.txt b/tests/baselines/reference/parserConstructorDeclaration12.errors.txt index 8f0a872a0af24..e094d5eed581c 100644 --- a/tests/baselines/reference/parserConstructorDeclaration12.errors.txt +++ b/tests/baselines/reference/parserConstructorDeclaration12.errors.txt @@ -1,85 +1,61 @@ tests/cases/compiler/parserConstructorDeclaration12.ts(2,3): error TS2392: Multiple constructor implementations are not allowed. -tests/cases/compiler/parserConstructorDeclaration12.ts(2,14): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(2,15): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(3,3): error TS2392: Multiple constructor implementations are not allowed. -tests/cases/compiler/parserConstructorDeclaration12.ts(3,14): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(3,15): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(4,3): error TS2392: Multiple constructor implementations are not allowed. -tests/cases/compiler/parserConstructorDeclaration12.ts(4,15): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(4,16): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(5,3): error TS2392: Multiple constructor implementations are not allowed. -tests/cases/compiler/parserConstructorDeclaration12.ts(5,15): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(5,16): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(6,3): error TS2392: Multiple constructor implementations are not allowed. -tests/cases/compiler/parserConstructorDeclaration12.ts(6,14): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(6,15): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(7,3): error TS2392: Multiple constructor implementations are not allowed. -tests/cases/compiler/parserConstructorDeclaration12.ts(7,14): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(7,15): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(8,3): error TS2392: Multiple constructor implementations are not allowed. -tests/cases/compiler/parserConstructorDeclaration12.ts(8,15): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(8,16): error TS1092: Type parameters cannot appear on a constructor declaration. tests/cases/compiler/parserConstructorDeclaration12.ts(9,3): error TS2392: Multiple constructor implementations are not allowed. -tests/cases/compiler/parserConstructorDeclaration12.ts(9,15): error TS1098: Type parameter list cannot be empty. tests/cases/compiler/parserConstructorDeclaration12.ts(9,16): error TS1092: Type parameters cannot appear on a constructor declaration. -==== tests/cases/compiler/parserConstructorDeclaration12.ts (24 errors) ==== +==== tests/cases/compiler/parserConstructorDeclaration12.ts (16 errors) ==== class C { constructor<>() { } ~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - ~~ -!!! error TS1098: Type parameter list cannot be empty. !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor<> () { } ~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - ~~ -!!! error TS1098: Type parameter list cannot be empty. !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor <>() { } ~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - ~~ -!!! error TS1098: Type parameter list cannot be empty. !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor <> () { } ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - ~~ -!!! error TS1098: Type parameter list cannot be empty. !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor< >() { } ~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - ~~~ -!!! error TS1098: Type parameter list cannot be empty. !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor< > () { } ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - ~~~ -!!! error TS1098: Type parameter list cannot be empty. !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor < >() { } ~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - ~~~ -!!! error TS1098: Type parameter list cannot be empty. !!! error TS1092: Type parameters cannot appear on a constructor declaration. constructor < > () { } ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS2392: Multiple constructor implementations are not allowed. - ~~~ -!!! error TS1098: Type parameter list cannot be empty. !!! error TS1092: Type parameters cannot appear on a constructor declaration. } \ No newline at end of file diff --git a/tests/baselines/reference/transformApi/transformsCorrectly.transformAddDecoratedNode.js b/tests/baselines/reference/transformApi/transformsCorrectly.transformAddDecoratedNode.js index de841226c064b..d45a68df66210 100644 --- a/tests/baselines/reference/transformApi/transformsCorrectly.transformAddDecoratedNode.js +++ b/tests/baselines/reference/transformApi/transformsCorrectly.transformAddDecoratedNode.js @@ -11,6 +11,5 @@ var Foo = /** @class */ (function () { __decorate([ Bar ], Foo.prototype, "baz", null); - Foo = __decorate([], Foo); return Foo; }()); diff --git a/tests/baselines/reference/typeGuardFunctionErrors.symbols b/tests/baselines/reference/typeGuardFunctionErrors.symbols index 9c7e82bf9abcd..7297afe231347 100644 --- a/tests/baselines/reference/typeGuardFunctionErrors.symbols +++ b/tests/baselines/reference/typeGuardFunctionErrors.symbols @@ -255,7 +255,6 @@ class D { constructor(p1: A): p1 is C { >p1 : Symbol(p1, Decl(typeGuardFunctionErrors.ts, 102, 16)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0)) ->p1 : Symbol(p1, Decl(typeGuardFunctionErrors.ts, 102, 16)) >C : Symbol(C, Decl(typeGuardFunctionErrors.ts, 6, 1)) return true; @@ -273,7 +272,6 @@ class D { >m2 : Symbol(D.m2, Decl(typeGuardFunctionErrors.ts, 107, 5)) >p1 : Symbol(p1, Decl(typeGuardFunctionErrors.ts, 108, 11)) >A : Symbol(A, Decl(typeGuardFunctionErrors.ts, 0, 0)) ->p1 : Symbol(p1, Decl(typeGuardFunctionErrors.ts, 108, 11)) >C : Symbol(C, Decl(typeGuardFunctionErrors.ts, 6, 1)) return true;