diff --git a/src/compiler/types.ts b/src/compiler/types.ts index f7567053c89cf..68af5c8860b8d 100644 --- a/src/compiler/types.ts +++ b/src/compiler/types.ts @@ -885,6 +885,144 @@ namespace ts { /* @internal */ jsDocCache?: readonly JSDocTag[]; // Cache for getJSDocTags } + /* @internal */ + export type HasChildren = + | Identifier + | QualifiedName + | ComputedPropertyName + | TypeParameterDeclaration + | ParameterDeclaration + | Decorator + | PropertySignature + | PropertyDeclaration + | MethodSignature + | MethodDeclaration + | ConstructorDeclaration + | GetAccessorDeclaration + | SetAccessorDeclaration + | ClassStaticBlockDeclaration + | CallSignatureDeclaration + | ConstructSignatureDeclaration + | IndexSignatureDeclaration + | TypePredicateNode + | TypeReferenceNode + | FunctionTypeNode + | ConstructorTypeNode + | TypeQueryNode + | TypeLiteralNode + | ArrayTypeNode + | TupleTypeNode + | OptionalTypeNode + | RestTypeNode + | UnionTypeNode + | IntersectionTypeNode + | ConditionalTypeNode + | InferTypeNode + | ImportTypeNode + | ImportTypeAssertionContainer + | NamedTupleMember + | ParenthesizedTypeNode + | TypeOperatorNode + | IndexedAccessTypeNode + | MappedTypeNode + | LiteralTypeNode + | TemplateLiteralTypeNode + | TemplateLiteralTypeSpan + | ObjectBindingPattern + | ArrayBindingPattern + | BindingElement + | ArrayLiteralExpression + | ObjectLiteralExpression + | PropertyAccessExpression + | ElementAccessExpression + | CallExpression + | NewExpression + | TaggedTemplateExpression + | TypeAssertion + | ParenthesizedExpression + | FunctionExpression + | ArrowFunction + | DeleteExpression + | TypeOfExpression + | VoidExpression + | AwaitExpression + | PrefixUnaryExpression + | PostfixUnaryExpression + | BinaryExpression + | ConditionalExpression + | TemplateExpression + | YieldExpression + | SpreadElement + | ClassExpression + | ExpressionWithTypeArguments + | AsExpression + | NonNullExpression + | MetaProperty + | TemplateSpan + | Block + | VariableStatement + | ExpressionStatement + | IfStatement + | DoStatement + | WhileStatement + | ForStatement + | ForInStatement + | ForOfStatement + | ContinueStatement + | BreakStatement + | ReturnStatement + | WithStatement + | SwitchStatement + | LabeledStatement + | ThrowStatement + | TryStatement + | VariableDeclaration + | VariableDeclarationList + | FunctionDeclaration + | ClassDeclaration + | InterfaceDeclaration + | TypeAliasDeclaration + | EnumDeclaration + | ModuleDeclaration + | ModuleBlock + | CaseBlock + | NamespaceExportDeclaration + | ImportEqualsDeclaration + | ImportDeclaration + | AssertClause + | AssertEntry + | ImportClause + | NamespaceImport + | NamespaceExport + | NamedImports + | ImportSpecifier + | ExportAssignment + | ExportDeclaration + | NamedExports + | ExportSpecifier + | ExternalModuleReference + | JsxElement + | JsxSelfClosingElement + | JsxOpeningElement + | JsxClosingElement + | JsxFragment + | JsxAttribute + | JsxAttributes + | JsxSpreadAttribute + | JsxExpression + | CaseClause + | DefaultClause + | HeritageClause + | CatchClause + | PropertyAssignment + | ShorthandPropertyAssignment + | SpreadAssignment + | EnumMember + | SourceFile + | PartiallyEmittedExpression + | CommaListExpression + ; + export type HasJSDoc = | ParameterDeclaration | CallSignatureDeclaration diff --git a/src/compiler/visitorPublic.ts b/src/compiler/visitorPublic.ts index 0842087535d47..94042c390edee 100644 --- a/src/compiler/visitorPublic.ts +++ b/src/compiler/visitorPublic.ts @@ -358,6 +358,774 @@ namespace ts { return updated; } + type VisitEachChildFunction = (node: T, visitor: Visitor, context: TransformationContext, nodesVisitor: NodesVisitor, nodeVisitor: NodeVisitor, tokenVisitor: Visitor | undefined) => T; + + type VisitEachChildTable = + & { [K in Exclude]?: undefined; } // nodes that don't have children are ignored + & { [TNode in HasChildren as TNode["kind"]]: VisitEachChildFunction }; // nodes that can have children must have funcitons + + const visitEachChildTable: VisitEachChildTable = { + [SyntaxKind.Identifier]: (node, visitor, _context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + factory.updateIdentifier(node, + nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)), + + [SyntaxKind.QualifiedName]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateQualifiedName(node, + nodeVisitor(node.left, visitor, isEntityName), + nodeVisitor(node.right, visitor, isIdentifier)), + + [SyntaxKind.ComputedPropertyName]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateComputedPropertyName(node, + nodeVisitor(node.expression, visitor, isExpression)), + + // Signature elements + [SyntaxKind.TypeParameter]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTypeParameterDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.name, visitor, isIdentifier), + nodeVisitor(node.constraint, visitor, isTypeNode), + nodeVisitor(node.default, visitor, isTypeNode)), + + [SyntaxKind.Parameter]: (node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateParameterDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifierLike), + nodeVisitor(node.dotDotDotToken, tokenVisitor, isDotDotDotToken), + nodeVisitor(node.name, visitor, isBindingName), + nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), + nodeVisitor(node.type, visitor, isTypeNode), + nodeVisitor(node.initializer, visitor, isExpression)), + + [SyntaxKind.Decorator]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateDecorator(node, + nodeVisitor(node.expression, visitor, isExpression)), + + // Type elements + [SyntaxKind.PropertySignature]: (node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updatePropertySignature(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.name, visitor, isPropertyName), + nodeVisitor(node.questionToken, tokenVisitor, isToken), + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.PropertyDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updatePropertyDeclaration(node, + 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), + nodeVisitor(node.type, visitor, isTypeNode), + nodeVisitor(node.initializer, visitor, isExpression)), + + [SyntaxKind.MethodSignature]: (node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateMethodSignature(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.name, visitor, isPropertyName), + nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + nodesVisitor(node.parameters, visitor, isParameterDeclaration), + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.MethodDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateMethodDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifierLike), + nodeVisitor(node.asteriskToken, tokenVisitor, isAsteriskToken), + nodeVisitor(node.name, visitor, isPropertyName), + nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + visitParameterList(node.parameters, visitor, context, nodesVisitor), + nodeVisitor(node.type, visitor, isTypeNode), + visitFunctionBody(node.body!, visitor, context, nodeVisitor)), + + [SyntaxKind.Constructor]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateConstructorDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifier), + visitParameterList(node.parameters, visitor, context, nodesVisitor), + visitFunctionBody(node.body!, visitor, context, nodeVisitor)), + + [SyntaxKind.GetAccessor]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateGetAccessorDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifierLike), + nodeVisitor(node.name, visitor, isPropertyName), + visitParameterList(node.parameters, visitor, context, nodesVisitor), + nodeVisitor(node.type, visitor, isTypeNode), + visitFunctionBody(node.body!, visitor, context, nodeVisitor)), + + [SyntaxKind.SetAccessor]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateSetAccessorDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifierLike), + nodeVisitor(node.name, visitor, isPropertyName), + visitParameterList(node.parameters, visitor, context, nodesVisitor), + visitFunctionBody(node.body!, visitor, context, nodeVisitor)), + + [SyntaxKind.ClassStaticBlockDeclaration]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => { + context.startLexicalEnvironment(); + context.suspendLexicalEnvironment(); + return context.factory.updateClassStaticBlockDeclaration(node, + visitFunctionBody(node.body, visitor, context, nodeVisitor)); + }, + + [SyntaxKind.CallSignature]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateCallSignature(node, + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + nodesVisitor(node.parameters, visitor, isParameterDeclaration), + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.ConstructSignature]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateConstructSignature(node, + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + nodesVisitor(node.parameters, visitor, isParameterDeclaration), + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.IndexSignature]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateIndexSignature(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodesVisitor(node.parameters, visitor, isParameterDeclaration), + nodeVisitor(node.type, visitor, isTypeNode)), + + // Types + [SyntaxKind.TypePredicate]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTypePredicateNode(node, + nodeVisitor(node.assertsModifier, visitor, isAssertsKeyword), + nodeVisitor(node.parameterName, visitor, isIdentifierOrThisTypeNode), + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.TypeReference]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTypeReferenceNode(node, + nodeVisitor(node.typeName, visitor, isEntityName), + nodesVisitor(node.typeArguments, visitor, isTypeNode)), + + [SyntaxKind.FunctionType]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateFunctionTypeNode(node, + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + nodesVisitor(node.parameters, visitor, isParameterDeclaration), + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.ConstructorType]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateConstructorTypeNode(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + nodesVisitor(node.parameters, visitor, isParameterDeclaration), + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.TypeQuery]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTypeQueryNode(node, + nodeVisitor(node.exprName, visitor, isEntityName), + nodesVisitor(node.typeArguments, visitor, isTypeNode)), + + [SyntaxKind.TypeLiteral]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateTypeLiteralNode(node, + nodesVisitor(node.members, visitor, isTypeElement)), + + [SyntaxKind.ArrayType]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateArrayTypeNode(node, + nodeVisitor(node.elementType, visitor, isTypeNode)), + + [SyntaxKind.TupleType]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateTupleTypeNode(node, + nodesVisitor(node.elements, visitor, isTypeNode)), + + [SyntaxKind.OptionalType]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateOptionalTypeNode(node, + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.RestType]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateRestTypeNode(node, + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.UnionType]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateUnionTypeNode(node, + nodesVisitor(node.types, visitor, isTypeNode)), + + [SyntaxKind.IntersectionType]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateIntersectionTypeNode(node, + nodesVisitor(node.types, visitor, isTypeNode)), + + [SyntaxKind.ConditionalType]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateConditionalTypeNode(node, + nodeVisitor(node.checkType, visitor, isTypeNode), + nodeVisitor(node.extendsType, visitor, isTypeNode), + nodeVisitor(node.trueType, visitor, isTypeNode), + nodeVisitor(node.falseType, visitor, isTypeNode)), + + [SyntaxKind.InferType]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateInferTypeNode(node, + nodeVisitor(node.typeParameter, visitor, isTypeParameterDeclaration)), + + [SyntaxKind.ImportType]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateImportTypeNode(node, + nodeVisitor(node.argument, visitor, isTypeNode), + nodeVisitor(node.assertions, visitor, isNode), + nodeVisitor(node.qualifier, visitor, isEntityName), + nodesVisitor(node.typeArguments, visitor, isTypeNode), + node.isTypeOf + ), + + [SyntaxKind.ImportTypeAssertionContainer]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateImportTypeAssertionContainer(node, + nodeVisitor(node.assertClause, visitor, isNode), + node.multiLine + ), + + [SyntaxKind.NamedTupleMember]: (node, visitor, context, _nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateNamedTupleMember(node, + nodeVisitor(node.dotDotDotToken, tokenVisitor, isDotDotDotToken), + nodeVisitor(node.name, visitor, isIdentifier), + nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), + nodeVisitor(node.type, visitor, isTypeNode), + ), + + [SyntaxKind.ParenthesizedType]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateParenthesizedType(node, + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.TypeOperator]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTypeOperatorNode(node, + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.IndexedAccessType]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateIndexedAccessTypeNode(node, + nodeVisitor(node.objectType, visitor, isTypeNode), + nodeVisitor(node.indexType, visitor, isTypeNode)), + + [SyntaxKind.MappedType]: (node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateMappedTypeNode(node, + nodeVisitor(node.readonlyToken, tokenVisitor, isReadonlyKeywordOrPlusOrMinusToken), + nodeVisitor(node.typeParameter, visitor, isTypeParameterDeclaration), + nodeVisitor(node.nameType, visitor, isTypeNode), + nodeVisitor(node.questionToken, tokenVisitor, isQuestionOrPlusOrMinusToken), + nodeVisitor(node.type, visitor, isTypeNode), + nodesVisitor(node.members, visitor, isTypeElement)), + + [SyntaxKind.LiteralType]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateLiteralTypeNode(node, + nodeVisitor(node.literal, visitor, isExpression)), + + [SyntaxKind.TemplateLiteralType]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTemplateLiteralType(node, + nodeVisitor(node.head, visitor, isTemplateHead), + nodesVisitor(node.templateSpans, visitor, isTemplateLiteralTypeSpan)), + + [SyntaxKind.TemplateLiteralTypeSpan]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTemplateLiteralTypeSpan(node, + nodeVisitor(node.type, visitor, isTypeNode), + nodeVisitor(node.literal, visitor, isTemplateMiddleOrTemplateTail)), + + // Binding patterns + [SyntaxKind.ObjectBindingPattern]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateObjectBindingPattern(node, + nodesVisitor(node.elements, visitor, isBindingElement)), + + [SyntaxKind.ArrayBindingPattern]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateArrayBindingPattern(node, + nodesVisitor(node.elements, visitor, isArrayBindingElement)), + + [SyntaxKind.BindingElement]: (node, visitor, context, _nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateBindingElement(node, + nodeVisitor(node.dotDotDotToken, tokenVisitor, isDotDotDotToken), + nodeVisitor(node.propertyName, visitor, isPropertyName), + nodeVisitor(node.name, visitor, isBindingName), + nodeVisitor(node.initializer, visitor, isExpression)), + + // Expression + [SyntaxKind.ArrayLiteralExpression]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateArrayLiteralExpression(node, + nodesVisitor(node.elements, visitor, isExpression)), + + [SyntaxKind.ObjectLiteralExpression]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateObjectLiteralExpression(node, + nodesVisitor(node.properties, visitor, isObjectLiteralElementLike)), + + [SyntaxKind.PropertyAccessExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, tokenVisitor) => + isPropertyAccessChain(node) ? + context.factory.updatePropertyAccessChain(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.questionDotToken, tokenVisitor, isQuestionDotToken), + nodeVisitor(node.name, visitor, isMemberName)) : + context.factory.updatePropertyAccessExpression(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.name, visitor, isMemberName)), + + [SyntaxKind.ElementAccessExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, tokenVisitor) => + isElementAccessChain(node) ? + context.factory.updateElementAccessChain(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.questionDotToken, tokenVisitor, isQuestionDotToken), + nodeVisitor(node.argumentExpression, visitor, isExpression)) : + context.factory.updateElementAccessExpression(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.argumentExpression, visitor, isExpression)), + + [SyntaxKind.CallExpression]: (node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor) => + isCallChain(node) ? + context.factory.updateCallChain(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.questionDotToken, tokenVisitor, isQuestionDotToken), + nodesVisitor(node.typeArguments, visitor, isTypeNode), + nodesVisitor(node.arguments, visitor, isExpression)) : + context.factory.updateCallExpression(node, + nodeVisitor(node.expression, visitor, isExpression), + nodesVisitor(node.typeArguments, visitor, isTypeNode), + nodesVisitor(node.arguments, visitor, isExpression)), + + [SyntaxKind.NewExpression]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateNewExpression(node, + nodeVisitor(node.expression, visitor, isExpression), + nodesVisitor(node.typeArguments, visitor, isTypeNode), + nodesVisitor(node.arguments, visitor, isExpression)), + + [SyntaxKind.TaggedTemplateExpression]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTaggedTemplateExpression(node, + nodeVisitor(node.tag, visitor, isExpression), + nodesVisitor(node.typeArguments, visitor, isTypeNode), + nodeVisitor(node.template, visitor, isTemplateLiteral)), + + [SyntaxKind.TypeAssertionExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTypeAssertion(node, + nodeVisitor(node.type, visitor, isTypeNode), + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.ParenthesizedExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateParenthesizedExpression(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.FunctionExpression]: (node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateFunctionExpression(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.asteriskToken, tokenVisitor, isAsteriskToken), + nodeVisitor(node.name, visitor, isIdentifier), + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + visitParameterList(node.parameters, visitor, context, nodesVisitor), + nodeVisitor(node.type, visitor, isTypeNode), + visitFunctionBody(node.body, visitor, context, nodeVisitor)), + + [SyntaxKind.ArrowFunction]: (node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateArrowFunction(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + visitParameterList(node.parameters, visitor, context, nodesVisitor), + nodeVisitor(node.type, visitor, isTypeNode), + nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, isEqualsGreaterThanToken), + visitFunctionBody(node.body, visitor, context, nodeVisitor)), + + [SyntaxKind.DeleteExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateDeleteExpression(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.TypeOfExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTypeOfExpression(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.VoidExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateVoidExpression(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.AwaitExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateAwaitExpression(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.PrefixUnaryExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updatePrefixUnaryExpression(node, + nodeVisitor(node.operand, visitor, isExpression)), + + [SyntaxKind.PostfixUnaryExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updatePostfixUnaryExpression(node, + nodeVisitor(node.operand, visitor, isExpression)), + + [SyntaxKind.BinaryExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateBinaryExpression(node, + nodeVisitor(node.left, visitor, isExpression), + nodeVisitor(node.operatorToken, tokenVisitor, isBinaryOperatorToken), + nodeVisitor(node.right, visitor, isExpression)), + + [SyntaxKind.ConditionalExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateConditionalExpression(node, + nodeVisitor(node.condition, visitor, isExpression), + nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), + nodeVisitor(node.whenTrue, visitor, isExpression), + nodeVisitor(node.colonToken, tokenVisitor, isColonToken), + nodeVisitor(node.whenFalse, visitor, isExpression)), + + [SyntaxKind.TemplateExpression]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTemplateExpression(node, + nodeVisitor(node.head, visitor, isTemplateHead), + nodesVisitor(node.templateSpans, visitor, isTemplateSpan)), + + [SyntaxKind.YieldExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateYieldExpression(node, + nodeVisitor(node.asteriskToken, tokenVisitor, isAsteriskToken), + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.SpreadElement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateSpreadElement(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.ClassExpression]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateClassExpression(node, + nodesVisitor(node.modifiers, visitor, isModifierLike), + nodeVisitor(node.name, visitor, isIdentifier), + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + nodesVisitor(node.heritageClauses, visitor, isHeritageClause), + nodesVisitor(node.members, visitor, isClassElement)), + + [SyntaxKind.ExpressionWithTypeArguments]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateExpressionWithTypeArguments(node, + nodeVisitor(node.expression, visitor, isExpression), + nodesVisitor(node.typeArguments, visitor, isTypeNode)), + + [SyntaxKind.AsExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateAsExpression(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.NonNullExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + isOptionalChain(node) ? + context.factory.updateNonNullChain(node, + nodeVisitor(node.expression, visitor, isExpression)) : + context.factory.updateNonNullExpression(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.MetaProperty]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateMetaProperty(node, + nodeVisitor(node.name, visitor, isIdentifier)), + + // Misc + [SyntaxKind.TemplateSpan]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTemplateSpan(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.literal, visitor, isTemplateMiddleOrTemplateTail)), + + // Element + [SyntaxKind.Block]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateBlock(node, + nodesVisitor(node.statements, visitor, isStatement)), + + [SyntaxKind.VariableStatement]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateVariableStatement(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.declarationList, visitor, isVariableDeclarationList)), + + [SyntaxKind.ExpressionStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateExpressionStatement(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.IfStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateIfStatement(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.thenStatement, visitor, isStatement, context.factory.liftToBlock), + nodeVisitor(node.elseStatement, visitor, isStatement, context.factory.liftToBlock)), + + [SyntaxKind.DoStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateDoStatement(node, + visitIterationBody(node.statement, visitor, context), + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.WhileStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateWhileStatement(node, + nodeVisitor(node.expression, visitor, isExpression), + visitIterationBody(node.statement, visitor, context)), + + [SyntaxKind.ForStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateForStatement(node, + nodeVisitor(node.initializer, visitor, isForInitializer), + nodeVisitor(node.condition, visitor, isExpression), + nodeVisitor(node.incrementor, visitor, isExpression), + visitIterationBody(node.statement, visitor, context)), + + [SyntaxKind.ForInStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateForInStatement(node, + nodeVisitor(node.initializer, visitor, isForInitializer), + nodeVisitor(node.expression, visitor, isExpression), + visitIterationBody(node.statement, visitor, context)), + + [SyntaxKind.ForOfStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateForOfStatement(node, + nodeVisitor(node.awaitModifier, tokenVisitor, isAwaitKeyword), + nodeVisitor(node.initializer, visitor, isForInitializer), + nodeVisitor(node.expression, visitor, isExpression), + visitIterationBody(node.statement, visitor, context)), + + [SyntaxKind.ContinueStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateContinueStatement(node, + nodeVisitor(node.label, visitor, isIdentifier)), + + [SyntaxKind.BreakStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateBreakStatement(node, + nodeVisitor(node.label, visitor, isIdentifier)), + + [SyntaxKind.ReturnStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateReturnStatement(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.WithStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateWithStatement(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.statement, visitor, isStatement, context.factory.liftToBlock)), + + [SyntaxKind.SwitchStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateSwitchStatement(node, + nodeVisitor(node.expression, visitor, isExpression), + nodeVisitor(node.caseBlock, visitor, isCaseBlock)), + + [SyntaxKind.LabeledStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateLabeledStatement(node, + nodeVisitor(node.label, visitor, isIdentifier), + nodeVisitor(node.statement, visitor, isStatement, context.factory.liftToBlock)), + + [SyntaxKind.ThrowStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateThrowStatement(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.TryStatement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTryStatement(node, + nodeVisitor(node.tryBlock, visitor, isBlock), + nodeVisitor(node.catchClause, visitor, isCatchClause), + nodeVisitor(node.finallyBlock, visitor, isBlock)), + + [SyntaxKind.VariableDeclaration]: (node, visitor, context, _nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateVariableDeclaration(node, + nodeVisitor(node.name, visitor, isBindingName), + nodeVisitor(node.exclamationToken, tokenVisitor, isExclamationToken), + nodeVisitor(node.type, visitor, isTypeNode), + nodeVisitor(node.initializer, visitor, isExpression)), + + [SyntaxKind.VariableDeclarationList]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateVariableDeclarationList(node, + nodesVisitor(node.declarations, visitor, isVariableDeclaration)), + + [SyntaxKind.FunctionDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor) => + context.factory.updateFunctionDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.asteriskToken, tokenVisitor, isAsteriskToken), + nodeVisitor(node.name, visitor, isIdentifier), + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + visitParameterList(node.parameters, visitor, context, nodesVisitor), + nodeVisitor(node.type, visitor, isTypeNode), + visitFunctionBody(node.body, visitor, context, nodeVisitor)), + + [SyntaxKind.ClassDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateClassDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifierLike), + nodeVisitor(node.name, visitor, isIdentifier), + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + nodesVisitor(node.heritageClauses, visitor, isHeritageClause), + nodesVisitor(node.members, visitor, isClassElement)), + + [SyntaxKind.InterfaceDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateInterfaceDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.name, visitor, isIdentifier), + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + nodesVisitor(node.heritageClauses, visitor, isHeritageClause), + nodesVisitor(node.members, visitor, isTypeElement)), + + [SyntaxKind.TypeAliasDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateTypeAliasDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.name, visitor, isIdentifier), + nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), + nodeVisitor(node.type, visitor, isTypeNode)), + + [SyntaxKind.EnumDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateEnumDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.name, visitor, isIdentifier), + nodesVisitor(node.members, visitor, isEnumMember)), + + [SyntaxKind.ModuleDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateModuleDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.name, visitor, isModuleName), + nodeVisitor(node.body, visitor, isModuleBody)), + + [SyntaxKind.ModuleBlock]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateModuleBlock(node, + nodesVisitor(node.statements, visitor, isStatement)), + + [SyntaxKind.CaseBlock]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateCaseBlock(node, + nodesVisitor(node.clauses, visitor, isCaseOrDefaultClause)), + + [SyntaxKind.NamespaceExportDeclaration]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateNamespaceExportDeclaration(node, + nodeVisitor(node.name, visitor, isIdentifier)), + + [SyntaxKind.ImportEqualsDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateImportEqualsDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifier), + node.isTypeOnly, + nodeVisitor(node.name, visitor, isIdentifier), + nodeVisitor(node.moduleReference, visitor, isModuleReference)), + + [SyntaxKind.ImportDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateImportDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.importClause, visitor, isImportClause), + nodeVisitor(node.moduleSpecifier, visitor, isExpression), + nodeVisitor(node.assertClause, visitor, isAssertClause)), + + [SyntaxKind.AssertClause]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateAssertClause(node, + nodesVisitor(node.elements, visitor, isAssertEntry), + node.multiLine), + + [SyntaxKind.AssertEntry]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateAssertEntry(node, + nodeVisitor(node.name, visitor, isAssertionKey), + nodeVisitor(node.value, visitor, isExpressionNode)), + + [SyntaxKind.ImportClause]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateImportClause(node, + node.isTypeOnly, + nodeVisitor(node.name, visitor, isIdentifier), + nodeVisitor(node.namedBindings, visitor, isNamedImportBindings)), + + [SyntaxKind.NamespaceImport]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateNamespaceImport(node, + nodeVisitor(node.name, visitor, isIdentifier)), + + [SyntaxKind.NamespaceExport]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateNamespaceExport(node, + nodeVisitor(node.name, visitor, isIdentifier)), + + [SyntaxKind.NamedImports]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateNamedImports(node, + nodesVisitor(node.elements, visitor, isImportSpecifier)), + + [SyntaxKind.ImportSpecifier]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateImportSpecifier(node, + node.isTypeOnly, + nodeVisitor(node.propertyName, visitor, isIdentifier), + nodeVisitor(node.name, visitor, isIdentifier)), + + [SyntaxKind.ExportAssignment]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateExportAssignment(node, + nodesVisitor(node.modifiers, visitor, isModifier), + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.ExportDeclaration]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateExportDeclaration(node, + nodesVisitor(node.modifiers, visitor, isModifier), + node.isTypeOnly, + nodeVisitor(node.exportClause, visitor, isNamedExportBindings), + nodeVisitor(node.moduleSpecifier, visitor, isExpression), + nodeVisitor(node.assertClause, visitor, isAssertClause)), + + [SyntaxKind.NamedExports]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateNamedExports(node, + nodesVisitor(node.elements, visitor, isExportSpecifier)), + + [SyntaxKind.ExportSpecifier]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateExportSpecifier(node, + node.isTypeOnly, + nodeVisitor(node.propertyName, visitor, isIdentifier), + nodeVisitor(node.name, visitor, isIdentifier)), + + // Module references + [SyntaxKind.ExternalModuleReference]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateExternalModuleReference(node, + nodeVisitor(node.expression, visitor, isExpression)), + + // JSX + [SyntaxKind.JsxElement]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateJsxElement(node, + nodeVisitor(node.openingElement, visitor, isJsxOpeningElement), + nodesVisitor(node.children, visitor, isJsxChild), + nodeVisitor(node.closingElement, visitor, isJsxClosingElement)), + + [SyntaxKind.JsxSelfClosingElement]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateJsxSelfClosingElement(node, + nodeVisitor(node.tagName, visitor, isJsxTagNameExpression), + nodesVisitor(node.typeArguments, visitor, isTypeNode), + nodeVisitor(node.attributes, visitor, isJsxAttributes)), + + [SyntaxKind.JsxOpeningElement]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateJsxOpeningElement(node, + nodeVisitor(node.tagName, visitor, isJsxTagNameExpression), + nodesVisitor(node.typeArguments, visitor, isTypeNode), + nodeVisitor(node.attributes, visitor, isJsxAttributes)), + + [SyntaxKind.JsxClosingElement]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateJsxClosingElement(node, + nodeVisitor(node.tagName, visitor, isJsxTagNameExpression)), + + [SyntaxKind.JsxFragment]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateJsxFragment(node, + nodeVisitor(node.openingFragment, visitor, isJsxOpeningFragment), + nodesVisitor(node.children, visitor, isJsxChild), + nodeVisitor(node.closingFragment, visitor, isJsxClosingFragment)), + + [SyntaxKind.JsxAttribute]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateJsxAttribute(node, + nodeVisitor(node.name, visitor, isIdentifier), + nodeVisitor(node.initializer, visitor, isStringLiteralOrJsxExpression)), + + [SyntaxKind.JsxAttributes]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateJsxAttributes(node, + nodesVisitor(node.properties, visitor, isJsxAttributeLike)), + + [SyntaxKind.JsxSpreadAttribute]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateJsxSpreadAttribute(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.JsxExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateJsxExpression(node, + nodeVisitor(node.expression, visitor, isExpression)), + + // Clauses + [SyntaxKind.CaseClause]: (node, visitor, context, nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateCaseClause(node, + nodeVisitor(node.expression, visitor, isExpression), + nodesVisitor(node.statements, visitor, isStatement)), + + [SyntaxKind.DefaultClause]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateDefaultClause(node, + nodesVisitor(node.statements, visitor, isStatement)), + + [SyntaxKind.HeritageClause]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateHeritageClause(node, + nodesVisitor(node.types, visitor, isExpressionWithTypeArguments)), + + [SyntaxKind.CatchClause]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateCatchClause(node, + nodeVisitor(node.variableDeclaration, visitor, isVariableDeclaration), + nodeVisitor(node.block, visitor, isBlock)), + + // Property assignments + [SyntaxKind.PropertyAssignment]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updatePropertyAssignment(node, + nodeVisitor(node.name, visitor, isPropertyName), + nodeVisitor(node.initializer, visitor, isExpression)), + + [SyntaxKind.ShorthandPropertyAssignment]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateShorthandPropertyAssignment(node, + nodeVisitor(node.name, visitor, isIdentifier), + nodeVisitor(node.objectAssignmentInitializer, visitor, isExpression)), + + [SyntaxKind.SpreadAssignment]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateSpreadAssignment(node, + nodeVisitor(node.expression, visitor, isExpression)), + + // Enum + [SyntaxKind.EnumMember]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updateEnumMember(node, + nodeVisitor(node.name, visitor, isPropertyName), + nodeVisitor(node.initializer, visitor, isExpression)), + + // Top-level nodes + [SyntaxKind.SourceFile]: (node, visitor, context, _nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateSourceFile(node, + visitLexicalEnvironment(node.statements, visitor, context)), + + // Transformation nodes + [SyntaxKind.PartiallyEmittedExpression]: (node, visitor, context, _nodesVisitor, nodeVisitor, _tokenVisitor) => + context.factory.updatePartiallyEmittedExpression(node, + nodeVisitor(node.expression, visitor, isExpression)), + + [SyntaxKind.CommaListExpression]: (node, visitor, context, nodesVisitor, _nodeVisitor, _tokenVisitor) => + context.factory.updateCommaListExpression(node, + nodesVisitor(node.elements, visitor, isExpression)), + }; + /** * Visits each child of a Node using the supplied visitor, possibly returning a new Node of the same kind in its place. * @@ -378,7 +1146,7 @@ namespace ts { export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: typeof visitNodes, tokenVisitor?: Visitor): T | undefined; /* @internal */ export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor?: NodesVisitor, tokenVisitor?: Visitor, nodeVisitor?: NodeVisitor): T | undefined; // eslint-disable-line @typescript-eslint/unified-signatures - export function visitEachChild(node: Node | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes, tokenVisitor?: Visitor, nodeVisitor: NodeVisitor = visitNode): Node | undefined { + export function visitEachChild(node: T | undefined, visitor: Visitor, context: TransformationContext, nodesVisitor = visitNodes, tokenVisitor?: Visitor, nodeVisitor: NodeVisitor = visitNode): T | undefined { if (node === undefined) { return undefined; } @@ -390,916 +1158,12 @@ namespace ts { return node; } - const factory = context.factory; - switch (kind) { - // Names - - case SyntaxKind.Identifier: - Debug.type(node); - return factory.updateIdentifier(node, - nodesVisitor(node.typeArguments, visitor, isTypeNodeOrTypeParameterDeclaration)); - - case SyntaxKind.QualifiedName: - Debug.type(node); - return factory.updateQualifiedName(node, - nodeVisitor(node.left, visitor, isEntityName), - nodeVisitor(node.right, visitor, isIdentifier)); - - case SyntaxKind.ComputedPropertyName: - Debug.type(node); - return factory.updateComputedPropertyName(node, - nodeVisitor(node.expression, visitor, isExpression)); - - // Signature elements - case SyntaxKind.TypeParameter: - Debug.type(node); - return factory.updateTypeParameterDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.name, visitor, isIdentifier), - nodeVisitor(node.constraint, visitor, isTypeNode), - nodeVisitor(node.default, visitor, isTypeNode)); - - case SyntaxKind.Parameter: - Debug.type(node); - return factory.updateParameterDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifierLike), - nodeVisitor(node.dotDotDotToken, tokenVisitor, isDotDotDotToken), - nodeVisitor(node.name, visitor, isBindingName), - nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), - nodeVisitor(node.type, visitor, isTypeNode), - nodeVisitor(node.initializer, visitor, isExpression)); - - case SyntaxKind.Decorator: - Debug.type(node); - return factory.updateDecorator(node, - nodeVisitor(node.expression, visitor, isExpression)); - - // Type elements - case SyntaxKind.PropertySignature: - Debug.type(node); - return factory.updatePropertySignature(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.name, visitor, isPropertyName), - nodeVisitor(node.questionToken, tokenVisitor, isToken), - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.PropertyDeclaration: - Debug.type(node); - return factory.updatePropertyDeclaration(node, - 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), - nodeVisitor(node.type, visitor, isTypeNode), - nodeVisitor(node.initializer, visitor, isExpression)); - - case SyntaxKind.MethodSignature: - Debug.type(node); - return factory.updateMethodSignature(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.name, visitor, isPropertyName), - nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - nodesVisitor(node.parameters, visitor, isParameterDeclaration), - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.MethodDeclaration: - Debug.type(node); - return factory.updateMethodDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifierLike), - nodeVisitor(node.asteriskToken, tokenVisitor, isAsteriskToken), - nodeVisitor(node.name, visitor, isPropertyName), - nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - visitParameterList(node.parameters, visitor, context, nodesVisitor), - nodeVisitor(node.type, visitor, isTypeNode), - visitFunctionBody(node.body!, visitor, context, nodeVisitor)); - - case SyntaxKind.Constructor: - Debug.type(node); - return factory.updateConstructorDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifier), - visitParameterList(node.parameters, visitor, context, nodesVisitor), - visitFunctionBody(node.body!, visitor, context, nodeVisitor)); - - case SyntaxKind.GetAccessor: - Debug.type(node); - return factory.updateGetAccessorDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifierLike), - nodeVisitor(node.name, visitor, isPropertyName), - visitParameterList(node.parameters, visitor, context, nodesVisitor), - nodeVisitor(node.type, visitor, isTypeNode), - visitFunctionBody(node.body!, visitor, context, nodeVisitor)); - - case SyntaxKind.SetAccessor: - Debug.type(node); - return factory.updateSetAccessorDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifierLike), - nodeVisitor(node.name, visitor, isPropertyName), - visitParameterList(node.parameters, visitor, context, nodesVisitor), - visitFunctionBody(node.body!, visitor, context, nodeVisitor)); - - case SyntaxKind.ClassStaticBlockDeclaration: - Debug.type(node); - context.startLexicalEnvironment(); - context.suspendLexicalEnvironment(); - return factory.updateClassStaticBlockDeclaration(node, - visitFunctionBody(node.body, visitor, context, nodeVisitor)); - - case SyntaxKind.CallSignature: - Debug.type(node); - return factory.updateCallSignature(node, - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - nodesVisitor(node.parameters, visitor, isParameterDeclaration), - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.ConstructSignature: - Debug.type(node); - return factory.updateConstructSignature(node, - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - nodesVisitor(node.parameters, visitor, isParameterDeclaration), - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.IndexSignature: - Debug.type(node); - return factory.updateIndexSignature(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodesVisitor(node.parameters, visitor, isParameterDeclaration), - nodeVisitor(node.type, visitor, isTypeNode)); - - // Types - case SyntaxKind.TypePredicate: - Debug.type(node); - return factory.updateTypePredicateNode(node, - nodeVisitor(node.assertsModifier, visitor, isAssertsKeyword), - nodeVisitor(node.parameterName, visitor, isIdentifierOrThisTypeNode), - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.TypeReference: - Debug.type(node); - return factory.updateTypeReferenceNode(node, - nodeVisitor(node.typeName, visitor, isEntityName), - nodesVisitor(node.typeArguments, visitor, isTypeNode)); - - case SyntaxKind.FunctionType: - Debug.type(node); - return factory.updateFunctionTypeNode(node, - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - nodesVisitor(node.parameters, visitor, isParameterDeclaration), - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.ConstructorType: - Debug.type(node); - return factory.updateConstructorTypeNode(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - nodesVisitor(node.parameters, visitor, isParameterDeclaration), - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.TypeQuery: - Debug.type(node); - return factory.updateTypeQueryNode(node, - nodeVisitor(node.exprName, visitor, isEntityName), - nodesVisitor(node.typeArguments, visitor, isTypeNode)); - - case SyntaxKind.TypeLiteral: - Debug.type(node); - return factory.updateTypeLiteralNode(node, - nodesVisitor(node.members, visitor, isTypeElement)); - - case SyntaxKind.ArrayType: - Debug.type(node); - return factory.updateArrayTypeNode(node, - nodeVisitor(node.elementType, visitor, isTypeNode)); - - case SyntaxKind.TupleType: - Debug.type(node); - return factory.updateTupleTypeNode(node, - nodesVisitor(node.elements, visitor, isTypeNode)); - - case SyntaxKind.OptionalType: - Debug.type(node); - return factory.updateOptionalTypeNode(node, - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.RestType: - Debug.type(node); - return factory.updateRestTypeNode(node, - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.UnionType: - Debug.type(node); - return factory.updateUnionTypeNode(node, - nodesVisitor(node.types, visitor, isTypeNode)); - - case SyntaxKind.IntersectionType: - Debug.type(node); - return factory.updateIntersectionTypeNode(node, - nodesVisitor(node.types, visitor, isTypeNode)); - - case SyntaxKind.ConditionalType: - Debug.type(node); - return factory.updateConditionalTypeNode(node, - nodeVisitor(node.checkType, visitor, isTypeNode), - nodeVisitor(node.extendsType, visitor, isTypeNode), - nodeVisitor(node.trueType, visitor, isTypeNode), - nodeVisitor(node.falseType, visitor, isTypeNode)); - - case SyntaxKind.InferType: - Debug.type(node); - return factory.updateInferTypeNode(node, - nodeVisitor(node.typeParameter, visitor, isTypeParameterDeclaration)); - - case SyntaxKind.ImportType: - Debug.type(node); - return factory.updateImportTypeNode(node, - nodeVisitor(node.argument, visitor, isTypeNode), - nodeVisitor(node.assertions, visitor, isNode), - nodeVisitor(node.qualifier, visitor, isEntityName), - nodesVisitor(node.typeArguments, visitor, isTypeNode), - node.isTypeOf - ); - - case SyntaxKind.ImportTypeAssertionContainer: - Debug.type(node); - return factory.updateImportTypeAssertionContainer(node, - nodeVisitor(node.assertClause, visitor, isNode), - node.multiLine - ); - - case SyntaxKind.NamedTupleMember: - Debug.type(node); - return factory.updateNamedTupleMember(node, - nodeVisitor(node.dotDotDotToken, tokenVisitor, isDotDotDotToken), - nodeVisitor(node.name, visitor, isIdentifier), - nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), - nodeVisitor(node.type, visitor, isTypeNode), - ); - - case SyntaxKind.ParenthesizedType: - Debug.type(node); - return factory.updateParenthesizedType(node, - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.TypeOperator: - Debug.type(node); - return factory.updateTypeOperatorNode(node, - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.IndexedAccessType: - Debug.type(node); - return factory.updateIndexedAccessTypeNode(node, - nodeVisitor(node.objectType, visitor, isTypeNode), - nodeVisitor(node.indexType, visitor, isTypeNode)); - - case SyntaxKind.MappedType: - Debug.type(node); - return factory.updateMappedTypeNode(node, - nodeVisitor(node.readonlyToken, tokenVisitor, isReadonlyKeywordOrPlusOrMinusToken), - nodeVisitor(node.typeParameter, visitor, isTypeParameterDeclaration), - nodeVisitor(node.nameType, visitor, isTypeNode), - nodeVisitor(node.questionToken, tokenVisitor, isQuestionOrPlusOrMinusToken), - nodeVisitor(node.type, visitor, isTypeNode), - nodesVisitor(node.members, visitor, isTypeElement)); - - case SyntaxKind.LiteralType: - Debug.type(node); - return factory.updateLiteralTypeNode(node, - nodeVisitor(node.literal, visitor, isExpression)); - - case SyntaxKind.TemplateLiteralType: - Debug.type(node); - return factory.updateTemplateLiteralType(node, - nodeVisitor(node.head, visitor, isTemplateHead), - nodesVisitor(node.templateSpans, visitor, isTemplateLiteralTypeSpan)); - - case SyntaxKind.TemplateLiteralTypeSpan: - Debug.type(node); - return factory.updateTemplateLiteralTypeSpan(node, - nodeVisitor(node.type, visitor, isTypeNode), - nodeVisitor(node.literal, visitor, isTemplateMiddleOrTemplateTail)); - - // Binding patterns - case SyntaxKind.ObjectBindingPattern: - Debug.type(node); - return factory.updateObjectBindingPattern(node, - nodesVisitor(node.elements, visitor, isBindingElement)); - - case SyntaxKind.ArrayBindingPattern: - Debug.type(node); - return factory.updateArrayBindingPattern(node, - nodesVisitor(node.elements, visitor, isArrayBindingElement)); - - case SyntaxKind.BindingElement: - Debug.type(node); - return factory.updateBindingElement(node, - nodeVisitor(node.dotDotDotToken, tokenVisitor, isDotDotDotToken), - nodeVisitor(node.propertyName, visitor, isPropertyName), - nodeVisitor(node.name, visitor, isBindingName), - nodeVisitor(node.initializer, visitor, isExpression)); - - // Expression - case SyntaxKind.ArrayLiteralExpression: - Debug.type(node); - return factory.updateArrayLiteralExpression(node, - nodesVisitor(node.elements, visitor, isExpression)); - - case SyntaxKind.ObjectLiteralExpression: - Debug.type(node); - return factory.updateObjectLiteralExpression(node, - nodesVisitor(node.properties, visitor, isObjectLiteralElementLike)); - - case SyntaxKind.PropertyAccessExpression: - if (node.flags & NodeFlags.OptionalChain) { - Debug.type(node); - return factory.updatePropertyAccessChain(node, - nodeVisitor(node.expression, visitor, isExpression), - nodeVisitor(node.questionDotToken, tokenVisitor, isQuestionDotToken), - nodeVisitor(node.name, visitor, isMemberName)); - } - Debug.type(node); - return factory.updatePropertyAccessExpression(node, - nodeVisitor(node.expression, visitor, isExpression), - nodeVisitor(node.name, visitor, isMemberName)); - - case SyntaxKind.ElementAccessExpression: - if (node.flags & NodeFlags.OptionalChain) { - Debug.type(node); - return factory.updateElementAccessChain(node, - nodeVisitor(node.expression, visitor, isExpression), - nodeVisitor(node.questionDotToken, tokenVisitor, isQuestionDotToken), - nodeVisitor(node.argumentExpression, visitor, isExpression)); - } - Debug.type(node); - return factory.updateElementAccessExpression(node, - nodeVisitor(node.expression, visitor, isExpression), - nodeVisitor(node.argumentExpression, visitor, isExpression)); - - case SyntaxKind.CallExpression: - if (node.flags & NodeFlags.OptionalChain) { - Debug.type(node); - return factory.updateCallChain(node, - nodeVisitor(node.expression, visitor, isExpression), - nodeVisitor(node.questionDotToken, tokenVisitor, isQuestionDotToken), - nodesVisitor(node.typeArguments, visitor, isTypeNode), - nodesVisitor(node.arguments, visitor, isExpression)); - } - Debug.type(node); - return factory.updateCallExpression(node, - nodeVisitor(node.expression, visitor, isExpression), - nodesVisitor(node.typeArguments, visitor, isTypeNode), - nodesVisitor(node.arguments, visitor, isExpression)); - - case SyntaxKind.NewExpression: - Debug.type(node); - return factory.updateNewExpression(node, - nodeVisitor(node.expression, visitor, isExpression), - nodesVisitor(node.typeArguments, visitor, isTypeNode), - nodesVisitor(node.arguments, visitor, isExpression)); - - case SyntaxKind.TaggedTemplateExpression: - Debug.type(node); - return factory.updateTaggedTemplateExpression(node, - nodeVisitor(node.tag, visitor, isExpression), - nodesVisitor(node.typeArguments, visitor, isTypeNode), - nodeVisitor(node.template, visitor, isTemplateLiteral)); - - case SyntaxKind.TypeAssertionExpression: - Debug.type(node); - return factory.updateTypeAssertion(node, - nodeVisitor(node.type, visitor, isTypeNode), - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.ParenthesizedExpression: - Debug.type(node); - return factory.updateParenthesizedExpression(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.FunctionExpression: - Debug.type(node); - return factory.updateFunctionExpression(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.asteriskToken, tokenVisitor, isAsteriskToken), - nodeVisitor(node.name, visitor, isIdentifier), - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - visitParameterList(node.parameters, visitor, context, nodesVisitor), - nodeVisitor(node.type, visitor, isTypeNode), - visitFunctionBody(node.body, visitor, context, nodeVisitor)); - - case SyntaxKind.ArrowFunction: - Debug.type(node); - return factory.updateArrowFunction(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - visitParameterList(node.parameters, visitor, context, nodesVisitor), - nodeVisitor(node.type, visitor, isTypeNode), - nodeVisitor(node.equalsGreaterThanToken, tokenVisitor, isEqualsGreaterThanToken), - visitFunctionBody(node.body, visitor, context, nodeVisitor)); - - case SyntaxKind.DeleteExpression: - Debug.type(node); - return factory.updateDeleteExpression(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.TypeOfExpression: - Debug.type(node); - return factory.updateTypeOfExpression(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.VoidExpression: - Debug.type(node); - return factory.updateVoidExpression(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.AwaitExpression: - Debug.type(node); - return factory.updateAwaitExpression(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.PrefixUnaryExpression: - Debug.type(node); - return factory.updatePrefixUnaryExpression(node, - nodeVisitor(node.operand, visitor, isExpression)); - - case SyntaxKind.PostfixUnaryExpression: - Debug.type(node); - return factory.updatePostfixUnaryExpression(node, - nodeVisitor(node.operand, visitor, isExpression)); - - case SyntaxKind.BinaryExpression: - Debug.type(node); - return factory.updateBinaryExpression(node, - nodeVisitor(node.left, visitor, isExpression), - nodeVisitor(node.operatorToken, tokenVisitor, isBinaryOperatorToken), - nodeVisitor(node.right, visitor, isExpression)); - - case SyntaxKind.ConditionalExpression: - Debug.type(node); - return factory.updateConditionalExpression(node, - nodeVisitor(node.condition, visitor, isExpression), - nodeVisitor(node.questionToken, tokenVisitor, isQuestionToken), - nodeVisitor(node.whenTrue, visitor, isExpression), - nodeVisitor(node.colonToken, tokenVisitor, isColonToken), - nodeVisitor(node.whenFalse, visitor, isExpression)); - - case SyntaxKind.TemplateExpression: - Debug.type(node); - return factory.updateTemplateExpression(node, - nodeVisitor(node.head, visitor, isTemplateHead), - nodesVisitor(node.templateSpans, visitor, isTemplateSpan)); - - case SyntaxKind.YieldExpression: - Debug.type(node); - return factory.updateYieldExpression(node, - nodeVisitor(node.asteriskToken, tokenVisitor, isAsteriskToken), - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.SpreadElement: - Debug.type(node); - return factory.updateSpreadElement(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.ClassExpression: - Debug.type(node); - return factory.updateClassExpression(node, - nodesVisitor(node.modifiers, visitor, isModifierLike), - nodeVisitor(node.name, visitor, isIdentifier), - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - nodesVisitor(node.heritageClauses, visitor, isHeritageClause), - nodesVisitor(node.members, visitor, isClassElement)); - - case SyntaxKind.ExpressionWithTypeArguments: - Debug.type(node); - return factory.updateExpressionWithTypeArguments(node, - nodeVisitor(node.expression, visitor, isExpression), - nodesVisitor(node.typeArguments, visitor, isTypeNode)); - - case SyntaxKind.AsExpression: - Debug.type(node); - return factory.updateAsExpression(node, - nodeVisitor(node.expression, visitor, isExpression), - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.NonNullExpression: - if (node.flags & NodeFlags.OptionalChain) { - Debug.type(node); - return factory.updateNonNullChain(node, - nodeVisitor(node.expression, visitor, isExpression)); - } - Debug.type(node); - return factory.updateNonNullExpression(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.MetaProperty: - Debug.type(node); - return factory.updateMetaProperty(node, - nodeVisitor(node.name, visitor, isIdentifier)); - - // Misc - case SyntaxKind.TemplateSpan: - Debug.type(node); - return factory.updateTemplateSpan(node, - nodeVisitor(node.expression, visitor, isExpression), - nodeVisitor(node.literal, visitor, isTemplateMiddleOrTemplateTail)); - - // Element - case SyntaxKind.Block: - Debug.type(node); - return factory.updateBlock(node, - nodesVisitor(node.statements, visitor, isStatement)); - - case SyntaxKind.VariableStatement: - Debug.type(node); - return factory.updateVariableStatement(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.declarationList, visitor, isVariableDeclarationList)); - - case SyntaxKind.ExpressionStatement: - Debug.type(node); - return factory.updateExpressionStatement(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.IfStatement: - Debug.type(node); - return factory.updateIfStatement(node, - nodeVisitor(node.expression, visitor, isExpression), - nodeVisitor(node.thenStatement, visitor, isStatement, factory.liftToBlock), - nodeVisitor(node.elseStatement, visitor, isStatement, factory.liftToBlock)); - - case SyntaxKind.DoStatement: - Debug.type(node); - return factory.updateDoStatement(node, - visitIterationBody(node.statement, visitor, context), - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.WhileStatement: - Debug.type(node); - return factory.updateWhileStatement(node, - nodeVisitor(node.expression, visitor, isExpression), - visitIterationBody(node.statement, visitor, context)); - - case SyntaxKind.ForStatement: - Debug.type(node); - return factory.updateForStatement(node, - nodeVisitor(node.initializer, visitor, isForInitializer), - nodeVisitor(node.condition, visitor, isExpression), - nodeVisitor(node.incrementor, visitor, isExpression), - visitIterationBody(node.statement, visitor, context)); - - case SyntaxKind.ForInStatement: - Debug.type(node); - return factory.updateForInStatement(node, - nodeVisitor(node.initializer, visitor, isForInitializer), - nodeVisitor(node.expression, visitor, isExpression), - visitIterationBody(node.statement, visitor, context)); - - case SyntaxKind.ForOfStatement: - Debug.type(node); - return factory.updateForOfStatement(node, - nodeVisitor(node.awaitModifier, tokenVisitor, isAwaitKeyword), - nodeVisitor(node.initializer, visitor, isForInitializer), - nodeVisitor(node.expression, visitor, isExpression), - visitIterationBody(node.statement, visitor, context)); - - case SyntaxKind.ContinueStatement: - Debug.type(node); - return factory.updateContinueStatement(node, - nodeVisitor(node.label, visitor, isIdentifier)); - - case SyntaxKind.BreakStatement: - Debug.type(node); - return factory.updateBreakStatement(node, - nodeVisitor(node.label, visitor, isIdentifier)); - - case SyntaxKind.ReturnStatement: - Debug.type(node); - return factory.updateReturnStatement(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.WithStatement: - Debug.type(node); - return factory.updateWithStatement(node, - nodeVisitor(node.expression, visitor, isExpression), - nodeVisitor(node.statement, visitor, isStatement, factory.liftToBlock)); - - case SyntaxKind.SwitchStatement: - Debug.type(node); - return factory.updateSwitchStatement(node, - nodeVisitor(node.expression, visitor, isExpression), - nodeVisitor(node.caseBlock, visitor, isCaseBlock)); - - case SyntaxKind.LabeledStatement: - Debug.type(node); - return factory.updateLabeledStatement(node, - nodeVisitor(node.label, visitor, isIdentifier), - nodeVisitor(node.statement, visitor, isStatement, factory.liftToBlock)); - - case SyntaxKind.ThrowStatement: - Debug.type(node); - return factory.updateThrowStatement(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.TryStatement: - Debug.type(node); - return factory.updateTryStatement(node, - nodeVisitor(node.tryBlock, visitor, isBlock), - nodeVisitor(node.catchClause, visitor, isCatchClause), - nodeVisitor(node.finallyBlock, visitor, isBlock)); - - case SyntaxKind.VariableDeclaration: - Debug.type(node); - return factory.updateVariableDeclaration(node, - nodeVisitor(node.name, visitor, isBindingName), - nodeVisitor(node.exclamationToken, tokenVisitor, isExclamationToken), - nodeVisitor(node.type, visitor, isTypeNode), - nodeVisitor(node.initializer, visitor, isExpression)); - - case SyntaxKind.VariableDeclarationList: - Debug.type(node); - return factory.updateVariableDeclarationList(node, - nodesVisitor(node.declarations, visitor, isVariableDeclaration)); - - case SyntaxKind.FunctionDeclaration: - Debug.type(node); - return factory.updateFunctionDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.asteriskToken, tokenVisitor, isAsteriskToken), - nodeVisitor(node.name, visitor, isIdentifier), - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - visitParameterList(node.parameters, visitor, context, nodesVisitor), - nodeVisitor(node.type, visitor, isTypeNode), - visitFunctionBody(node.body, visitor, context, nodeVisitor)); - - case SyntaxKind.ClassDeclaration: - Debug.type(node); - return factory.updateClassDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifierLike), - nodeVisitor(node.name, visitor, isIdentifier), - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - nodesVisitor(node.heritageClauses, visitor, isHeritageClause), - nodesVisitor(node.members, visitor, isClassElement)); - - case SyntaxKind.InterfaceDeclaration: - Debug.type(node); - return factory.updateInterfaceDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.name, visitor, isIdentifier), - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - nodesVisitor(node.heritageClauses, visitor, isHeritageClause), - nodesVisitor(node.members, visitor, isTypeElement)); - - case SyntaxKind.TypeAliasDeclaration: - Debug.type(node); - return factory.updateTypeAliasDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.name, visitor, isIdentifier), - nodesVisitor(node.typeParameters, visitor, isTypeParameterDeclaration), - nodeVisitor(node.type, visitor, isTypeNode)); - - case SyntaxKind.EnumDeclaration: - Debug.type(node); - return factory.updateEnumDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.name, visitor, isIdentifier), - nodesVisitor(node.members, visitor, isEnumMember)); - - case SyntaxKind.ModuleDeclaration: - Debug.type(node); - return factory.updateModuleDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.name, visitor, isModuleName), - nodeVisitor(node.body, visitor, isModuleBody)); - - case SyntaxKind.ModuleBlock: - Debug.type(node); - return factory.updateModuleBlock(node, - nodesVisitor(node.statements, visitor, isStatement)); - - case SyntaxKind.CaseBlock: - Debug.type(node); - return factory.updateCaseBlock(node, - nodesVisitor(node.clauses, visitor, isCaseOrDefaultClause)); - - case SyntaxKind.NamespaceExportDeclaration: - Debug.type(node); - return factory.updateNamespaceExportDeclaration(node, - nodeVisitor(node.name, visitor, isIdentifier)); - - case SyntaxKind.ImportEqualsDeclaration: - Debug.type(node); - return factory.updateImportEqualsDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifier), - node.isTypeOnly, - nodeVisitor(node.name, visitor, isIdentifier), - nodeVisitor(node.moduleReference, visitor, isModuleReference)); - - case SyntaxKind.ImportDeclaration: - Debug.type(node); - return factory.updateImportDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.importClause, visitor, isImportClause), - nodeVisitor(node.moduleSpecifier, visitor, isExpression), - nodeVisitor(node.assertClause, visitor, isAssertClause)); - - case SyntaxKind.AssertClause: - Debug.type(node); - return factory.updateAssertClause(node, - nodesVisitor(node.elements, visitor, isAssertEntry), - node.multiLine); - - case SyntaxKind.AssertEntry: - Debug.type(node); - return factory.updateAssertEntry(node, - nodeVisitor(node.name, visitor, isAssertionKey), - nodeVisitor(node.value, visitor, isExpressionNode)); - - case SyntaxKind.ImportClause: - Debug.type(node); - return factory.updateImportClause(node, - node.isTypeOnly, - nodeVisitor(node.name, visitor, isIdentifier), - nodeVisitor(node.namedBindings, visitor, isNamedImportBindings)); - - case SyntaxKind.NamespaceImport: - Debug.type(node); - return factory.updateNamespaceImport(node, - nodeVisitor(node.name, visitor, isIdentifier)); - - case SyntaxKind.NamespaceExport: - Debug.type(node); - return factory.updateNamespaceExport(node, - nodeVisitor(node.name, visitor, isIdentifier)); - - case SyntaxKind.NamedImports: - Debug.type(node); - return factory.updateNamedImports(node, - nodesVisitor(node.elements, visitor, isImportSpecifier)); - - case SyntaxKind.ImportSpecifier: - Debug.type(node); - return factory.updateImportSpecifier(node, - node.isTypeOnly, - nodeVisitor(node.propertyName, visitor, isIdentifier), - nodeVisitor(node.name, visitor, isIdentifier)); - - case SyntaxKind.ExportAssignment: - Debug.type(node); - return factory.updateExportAssignment(node, - nodesVisitor(node.modifiers, visitor, isModifier), - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.ExportDeclaration: - Debug.type(node); - return factory.updateExportDeclaration(node, - nodesVisitor(node.modifiers, visitor, isModifier), - node.isTypeOnly, - nodeVisitor(node.exportClause, visitor, isNamedExportBindings), - nodeVisitor(node.moduleSpecifier, visitor, isExpression), - nodeVisitor(node.assertClause, visitor, isAssertClause)); - - case SyntaxKind.NamedExports: - Debug.type(node); - return factory.updateNamedExports(node, - nodesVisitor(node.elements, visitor, isExportSpecifier)); - - case SyntaxKind.ExportSpecifier: - Debug.type(node); - return factory.updateExportSpecifier(node, - node.isTypeOnly, - nodeVisitor(node.propertyName, visitor, isIdentifier), - nodeVisitor(node.name, visitor, isIdentifier)); - - // Module references - case SyntaxKind.ExternalModuleReference: - Debug.type(node); - return factory.updateExternalModuleReference(node, - nodeVisitor(node.expression, visitor, isExpression)); - - // JSX - case SyntaxKind.JsxElement: - Debug.type(node); - return factory.updateJsxElement(node, - nodeVisitor(node.openingElement, visitor, isJsxOpeningElement), - nodesVisitor(node.children, visitor, isJsxChild), - nodeVisitor(node.closingElement, visitor, isJsxClosingElement)); - - case SyntaxKind.JsxSelfClosingElement: - Debug.type(node); - return factory.updateJsxSelfClosingElement(node, - nodeVisitor(node.tagName, visitor, isJsxTagNameExpression), - nodesVisitor(node.typeArguments, visitor, isTypeNode), - nodeVisitor(node.attributes, visitor, isJsxAttributes)); - - case SyntaxKind.JsxOpeningElement: - Debug.type(node); - return factory.updateJsxOpeningElement(node, - nodeVisitor(node.tagName, visitor, isJsxTagNameExpression), - nodesVisitor(node.typeArguments, visitor, isTypeNode), - nodeVisitor(node.attributes, visitor, isJsxAttributes)); - - case SyntaxKind.JsxClosingElement: - Debug.type(node); - return factory.updateJsxClosingElement(node, - nodeVisitor(node.tagName, visitor, isJsxTagNameExpression)); - - case SyntaxKind.JsxFragment: - Debug.type(node); - return factory.updateJsxFragment(node, - nodeVisitor(node.openingFragment, visitor, isJsxOpeningFragment), - nodesVisitor(node.children, visitor, isJsxChild), - nodeVisitor(node.closingFragment, visitor, isJsxClosingFragment)); - - case SyntaxKind.JsxAttribute: - Debug.type(node); - return factory.updateJsxAttribute(node, - nodeVisitor(node.name, visitor, isIdentifier), - nodeVisitor(node.initializer, visitor, isStringLiteralOrJsxExpression)); - - case SyntaxKind.JsxAttributes: - Debug.type(node); - return factory.updateJsxAttributes(node, - nodesVisitor(node.properties, visitor, isJsxAttributeLike)); - - case SyntaxKind.JsxSpreadAttribute: - Debug.type(node); - return factory.updateJsxSpreadAttribute(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.JsxExpression: - Debug.type(node); - return factory.updateJsxExpression(node, - nodeVisitor(node.expression, visitor, isExpression)); - - // Clauses - case SyntaxKind.CaseClause: - Debug.type(node); - return factory.updateCaseClause(node, - nodeVisitor(node.expression, visitor, isExpression), - nodesVisitor(node.statements, visitor, isStatement)); - - case SyntaxKind.DefaultClause: - Debug.type(node); - return factory.updateDefaultClause(node, - nodesVisitor(node.statements, visitor, isStatement)); - - case SyntaxKind.HeritageClause: - Debug.type(node); - return factory.updateHeritageClause(node, - nodesVisitor(node.types, visitor, isExpressionWithTypeArguments)); - - case SyntaxKind.CatchClause: - Debug.type(node); - return factory.updateCatchClause(node, - nodeVisitor(node.variableDeclaration, visitor, isVariableDeclaration), - nodeVisitor(node.block, visitor, isBlock)); - - // Property assignments - case SyntaxKind.PropertyAssignment: - Debug.type(node); - return factory.updatePropertyAssignment(node, - nodeVisitor(node.name, visitor, isPropertyName), - nodeVisitor(node.initializer, visitor, isExpression)); - - case SyntaxKind.ShorthandPropertyAssignment: - Debug.type(node); - return factory.updateShorthandPropertyAssignment(node, - nodeVisitor(node.name, visitor, isIdentifier), - nodeVisitor(node.objectAssignmentInitializer, visitor, isExpression)); - - case SyntaxKind.SpreadAssignment: - Debug.type(node); - return factory.updateSpreadAssignment(node, - nodeVisitor(node.expression, visitor, isExpression)); - - // Enum - case SyntaxKind.EnumMember: - Debug.type(node); - return factory.updateEnumMember(node, - nodeVisitor(node.name, visitor, isPropertyName), - nodeVisitor(node.initializer, visitor, isExpression)); - - // Top-level nodes - case SyntaxKind.SourceFile: - Debug.type(node); - return factory.updateSourceFile(node, - visitLexicalEnvironment(node.statements, visitor, context)); - - // Transformation nodes - case SyntaxKind.PartiallyEmittedExpression: - Debug.type(node); - return factory.updatePartiallyEmittedExpression(node, - nodeVisitor(node.expression, visitor, isExpression)); - - case SyntaxKind.CommaListExpression: - Debug.type(node); - return factory.updateCommaListExpression(node, - nodesVisitor(node.elements, visitor, isExpression)); - - default: - // No need to visit nodes with no children. - return node; + const fn = visitEachChildTable[kind] as VisitEachChildFunction | undefined; + if (fn !== undefined) { + return fn(node, visitor, context, nodesVisitor, nodeVisitor, tokenVisitor); } + return node; } /**