From 09f4b074a80b6761eff54b7957b350c207fa6c2e Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Sat, 5 Jun 2021 01:44:58 +0200 Subject: [PATCH 1/7] babel-types: simplify generated builder wrappers ... ... by passing the node `type` string in `this` --- packages/babel-types/scripts/generators/builders.js | 4 ++-- packages/babel-types/src/builders/builder.ts | 10 ++++------ 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/packages/babel-types/scripts/generators/builders.js b/packages/babel-types/scripts/generators/builders.js index 3a30e6053c1f..6805af49571a 100644 --- a/packages/babel-types/scripts/generators/builders.js +++ b/packages/babel-types/scripts/generators/builders.js @@ -100,7 +100,7 @@ import type * as t from "../.."; formatedBuilderNameLocal === formatedBuilderName ? "export " : "" }function ${formatedBuilderNameLocal}(${defArgs.join( ", " - )}): t.${type} { return builder("${type}", ...arguments); }\n`; + )}): t.${type} { return builder.apply("${type}", arguments); }\n`; if (formatedBuilderNameLocal !== formatedBuilderName) { output += `export { ${formatedBuilderNameLocal} as ${formatedBuilderName} };\n`; } @@ -121,7 +121,7 @@ import type * as t from "../.."; output += `/** @deprecated */ function ${type}(...args: Array): any { console.trace("The node type ${type} has been renamed to ${newType}"); - return builder("${type}", ...args); + return builder.apply("${type}", arguments); } export { ${type} as ${formatedBuilderName} };\n`; // This is needed for backwards compatibility. diff --git a/packages/babel-types/src/builders/builder.ts b/packages/babel-types/src/builders/builder.ts index ae28dfc54b59..7e2e3b2bdfdb 100644 --- a/packages/babel-types/src/builders/builder.ts +++ b/packages/babel-types/src/builders/builder.ts @@ -2,12 +2,10 @@ import { NODE_FIELDS, BUILDER_KEYS } from "../definitions"; import validate from "../validators/validate"; import type * as t from ".."; -export default function builder( - type: T["type"], - ...args: Array -): T { +export default function builder(this: T["type"]): T { + const type = this; const keys = BUILDER_KEYS[type]; - const countArgs = args.length; + const countArgs = arguments.length; if (countArgs > keys.length) { throw new Error( `${type}: Too many arguments passed. Received ${countArgs} but can receive no more than ${keys.length}`, @@ -21,7 +19,7 @@ export default function builder( const field = NODE_FIELDS[type][key]; let arg; - if (i < countArgs) arg = args[i]; + if (i < countArgs) arg = arguments[i]; if (arg === undefined) { arg = Array.isArray(field.default) ? [] : field.default; } From 10796ad1d886fa0289b1ab560c4c684f1e01a38e Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Wed, 13 Oct 2021 01:28:33 +0200 Subject: [PATCH 2/7] replace `.forEach` with a loop to avoid closure over `arguments` --- packages/babel-types/src/builders/builder.ts | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/babel-types/src/builders/builder.ts b/packages/babel-types/src/builders/builder.ts index 7e2e3b2bdfdb..ed6b1d899115 100644 --- a/packages/babel-types/src/builders/builder.ts +++ b/packages/babel-types/src/builders/builder.ts @@ -14,8 +14,8 @@ export default function builder(this: T["type"]): T { const node = { type }; - let i = 0; - keys.forEach(key => { + for (let i = 0; i < keys.length; ++i) { + const key = keys[i]; const field = NODE_FIELDS[type][key]; let arg; @@ -25,8 +25,7 @@ export default function builder(this: T["type"]): T { } node[key] = arg; - i++; - }); + } for (const key of Object.keys(node)) { validate(node as t.Node, key, node[key]); From 3c5847eece3ffd72545320b56932d2dffe97d77b Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Wed, 13 Oct 2021 01:54:22 +0200 Subject: [PATCH 3/7] replace `for..of` loop with `for..in` when iterating over fresh object --- packages/babel-types/src/builders/builder.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/babel-types/src/builders/builder.ts b/packages/babel-types/src/builders/builder.ts index ed6b1d899115..26ae3ffda4a9 100644 --- a/packages/babel-types/src/builders/builder.ts +++ b/packages/babel-types/src/builders/builder.ts @@ -27,7 +27,9 @@ export default function builder(this: T["type"]): T { node[key] = arg; } - for (const key of Object.keys(node)) { + // (assume all enumerable properties are own) + // eslint-disable-next-line guard-for-in + for (const key in node) { validate(node as t.Node, key, node[key]); } From 0c12b5d970c05200a5df91de6d688ad957325354 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Wed, 13 Oct 2021 02:28:03 +0200 Subject: [PATCH 4/7] concat multiple arrays at once --- packages/babel-types/src/definitions/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/packages/babel-types/src/definitions/index.ts b/packages/babel-types/src/definitions/index.ts index 453d8c002598..a420122dcf61 100644 --- a/packages/babel-types/src/definitions/index.ts +++ b/packages/babel-types/src/definitions/index.ts @@ -31,9 +31,11 @@ toFastProperties(DEPRECATED_KEYS); toFastProperties(PLACEHOLDERS_ALIAS); toFastProperties(PLACEHOLDERS_FLIPPED_ALIAS); -const TYPES: Array = Object.keys(VISITOR_KEYS) - .concat(Object.keys(FLIPPED_ALIAS_KEYS)) - .concat(Object.keys(DEPRECATED_KEYS)); +const TYPES: Array = [].concat( + Object.keys(VISITOR_KEYS), + Object.keys(FLIPPED_ALIAS_KEYS), + Object.keys(DEPRECATED_KEYS), +); export { VISITOR_KEYS, From f6acaa2cb30b8866bd648a5384553ea225979571 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Wed, 13 Oct 2021 02:29:39 +0200 Subject: [PATCH 5/7] chore: gulp generate-type-helpers --- .../src/builders/generated/index.ts | 500 +++++++++--------- 1 file changed, 250 insertions(+), 250 deletions(-) diff --git a/packages/babel-types/src/builders/generated/index.ts b/packages/babel-types/src/builders/generated/index.ts index 7688db8b46be..6b2704fadabe 100755 --- a/packages/babel-types/src/builders/generated/index.ts +++ b/packages/babel-types/src/builders/generated/index.ts @@ -10,14 +10,14 @@ import type * as t from "../.."; export function arrayExpression( elements?: Array, ): t.ArrayExpression { - return builder("ArrayExpression", ...arguments); + return builder.apply("ArrayExpression", arguments); } export function assignmentExpression( operator: string, left: t.LVal, right: t.Expression, ): t.AssignmentExpression { - return builder("AssignmentExpression", ...arguments); + return builder.apply("AssignmentExpression", arguments); } export function binaryExpression( operator: @@ -46,25 +46,25 @@ export function binaryExpression( left: t.Expression | t.PrivateName, right: t.Expression, ): t.BinaryExpression { - return builder("BinaryExpression", ...arguments); + return builder.apply("BinaryExpression", arguments); } export function interpreterDirective(value: string): t.InterpreterDirective { - return builder("InterpreterDirective", ...arguments); + return builder.apply("InterpreterDirective", arguments); } export function directive(value: t.DirectiveLiteral): t.Directive { - return builder("Directive", ...arguments); + return builder.apply("Directive", arguments); } export function directiveLiteral(value: string): t.DirectiveLiteral { - return builder("DirectiveLiteral", ...arguments); + return builder.apply("DirectiveLiteral", arguments); } export function blockStatement( body: Array, directives?: Array, ): t.BlockStatement { - return builder("BlockStatement", ...arguments); + return builder.apply("BlockStatement", arguments); } export function breakStatement(label?: t.Identifier | null): t.BreakStatement { - return builder("BreakStatement", ...arguments); + return builder.apply("BreakStatement", arguments); } export function callExpression( callee: t.Expression | t.V8IntrinsicIdentifier, @@ -72,56 +72,56 @@ export function callExpression( t.Expression | t.SpreadElement | t.JSXNamespacedName | t.ArgumentPlaceholder >, ): t.CallExpression { - return builder("CallExpression", ...arguments); + return builder.apply("CallExpression", arguments); } export function catchClause( param: t.Identifier | t.ArrayPattern | t.ObjectPattern | null | undefined, body: t.BlockStatement, ): t.CatchClause { - return builder("CatchClause", ...arguments); + return builder.apply("CatchClause", arguments); } export function conditionalExpression( test: t.Expression, consequent: t.Expression, alternate: t.Expression, ): t.ConditionalExpression { - return builder("ConditionalExpression", ...arguments); + return builder.apply("ConditionalExpression", arguments); } export function continueStatement( label?: t.Identifier | null, ): t.ContinueStatement { - return builder("ContinueStatement", ...arguments); + return builder.apply("ContinueStatement", arguments); } export function debuggerStatement(): t.DebuggerStatement { - return builder("DebuggerStatement", ...arguments); + return builder.apply("DebuggerStatement", arguments); } export function doWhileStatement( test: t.Expression, body: t.Statement, ): t.DoWhileStatement { - return builder("DoWhileStatement", ...arguments); + return builder.apply("DoWhileStatement", arguments); } export function emptyStatement(): t.EmptyStatement { - return builder("EmptyStatement", ...arguments); + return builder.apply("EmptyStatement", arguments); } export function expressionStatement( expression: t.Expression, ): t.ExpressionStatement { - return builder("ExpressionStatement", ...arguments); + return builder.apply("ExpressionStatement", arguments); } export function file( program: t.Program, comments?: Array | null, tokens?: Array | null, ): t.File { - return builder("File", ...arguments); + return builder.apply("File", arguments); } export function forInStatement( left: t.VariableDeclaration | t.LVal, right: t.Expression, body: t.Statement, ): t.ForInStatement { - return builder("ForInStatement", ...arguments); + return builder.apply("ForInStatement", arguments); } export function forStatement( init: t.VariableDeclaration | t.Expression | null | undefined, @@ -129,7 +129,7 @@ export function forStatement( update: t.Expression | null | undefined, body: t.Statement, ): t.ForStatement { - return builder("ForStatement", ...arguments); + return builder.apply("ForStatement", arguments); } export function functionDeclaration( id: t.Identifier | null | undefined, @@ -138,7 +138,7 @@ export function functionDeclaration( generator?: boolean, async?: boolean, ): t.FunctionDeclaration { - return builder("FunctionDeclaration", ...arguments); + return builder.apply("FunctionDeclaration", arguments); } export function functionExpression( id: t.Identifier | null | undefined, @@ -147,48 +147,48 @@ export function functionExpression( generator?: boolean, async?: boolean, ): t.FunctionExpression { - return builder("FunctionExpression", ...arguments); + return builder.apply("FunctionExpression", arguments); } export function identifier(name: string): t.Identifier { - return builder("Identifier", ...arguments); + return builder.apply("Identifier", arguments); } export function ifStatement( test: t.Expression, consequent: t.Statement, alternate?: t.Statement | null, ): t.IfStatement { - return builder("IfStatement", ...arguments); + return builder.apply("IfStatement", arguments); } export function labeledStatement( label: t.Identifier, body: t.Statement, ): t.LabeledStatement { - return builder("LabeledStatement", ...arguments); + return builder.apply("LabeledStatement", arguments); } export function stringLiteral(value: string): t.StringLiteral { - return builder("StringLiteral", ...arguments); + return builder.apply("StringLiteral", arguments); } export function numericLiteral(value: number): t.NumericLiteral { - return builder("NumericLiteral", ...arguments); + return builder.apply("NumericLiteral", arguments); } export function nullLiteral(): t.NullLiteral { - return builder("NullLiteral", ...arguments); + return builder.apply("NullLiteral", arguments); } export function booleanLiteral(value: boolean): t.BooleanLiteral { - return builder("BooleanLiteral", ...arguments); + return builder.apply("BooleanLiteral", arguments); } export function regExpLiteral( pattern: string, flags?: string, ): t.RegExpLiteral { - return builder("RegExpLiteral", ...arguments); + return builder.apply("RegExpLiteral", arguments); } export function logicalExpression( operator: "||" | "&&" | "??", left: t.Expression, right: t.Expression, ): t.LogicalExpression { - return builder("LogicalExpression", ...arguments); + return builder.apply("LogicalExpression", arguments); } export function memberExpression( object: t.Expression, @@ -196,7 +196,7 @@ export function memberExpression( computed?: boolean, optional?: true | false | null, ): t.MemberExpression { - return builder("MemberExpression", ...arguments); + return builder.apply("MemberExpression", arguments); } export function newExpression( callee: t.Expression | t.V8IntrinsicIdentifier, @@ -204,7 +204,7 @@ export function newExpression( t.Expression | t.SpreadElement | t.JSXNamespacedName | t.ArgumentPlaceholder >, ): t.NewExpression { - return builder("NewExpression", ...arguments); + return builder.apply("NewExpression", arguments); } export function program( body: Array, @@ -212,12 +212,12 @@ export function program( sourceType?: "script" | "module", interpreter?: t.InterpreterDirective | null, ): t.Program { - return builder("Program", ...arguments); + return builder.apply("Program", arguments); } export function objectExpression( properties: Array, ): t.ObjectExpression { - return builder("ObjectExpression", ...arguments); + return builder.apply("ObjectExpression", arguments); } export function objectMethod( kind: "method" | "get" | "set" | undefined, @@ -228,7 +228,7 @@ export function objectMethod( generator?: boolean, async?: boolean, ): t.ObjectMethod { - return builder("ObjectMethod", ...arguments); + return builder.apply("ObjectMethod", arguments); } export function objectProperty( key: t.Expression | t.Identifier | t.StringLiteral | t.NumericLiteral, @@ -237,106 +237,106 @@ export function objectProperty( shorthand?: boolean, decorators?: Array | null, ): t.ObjectProperty { - return builder("ObjectProperty", ...arguments); + return builder.apply("ObjectProperty", arguments); } export function restElement(argument: t.LVal): t.RestElement { - return builder("RestElement", ...arguments); + return builder.apply("RestElement", arguments); } export function returnStatement( argument?: t.Expression | null, ): t.ReturnStatement { - return builder("ReturnStatement", ...arguments); + return builder.apply("ReturnStatement", arguments); } export function sequenceExpression( expressions: Array, ): t.SequenceExpression { - return builder("SequenceExpression", ...arguments); + return builder.apply("SequenceExpression", arguments); } export function parenthesizedExpression( expression: t.Expression, ): t.ParenthesizedExpression { - return builder("ParenthesizedExpression", ...arguments); + return builder.apply("ParenthesizedExpression", arguments); } export function switchCase( test: t.Expression | null | undefined, consequent: Array, ): t.SwitchCase { - return builder("SwitchCase", ...arguments); + return builder.apply("SwitchCase", arguments); } export function switchStatement( discriminant: t.Expression, cases: Array, ): t.SwitchStatement { - return builder("SwitchStatement", ...arguments); + return builder.apply("SwitchStatement", arguments); } export function thisExpression(): t.ThisExpression { - return builder("ThisExpression", ...arguments); + return builder.apply("ThisExpression", arguments); } export function throwStatement(argument: t.Expression): t.ThrowStatement { - return builder("ThrowStatement", ...arguments); + return builder.apply("ThrowStatement", arguments); } export function tryStatement( block: t.BlockStatement, handler?: t.CatchClause | null, finalizer?: t.BlockStatement | null, ): t.TryStatement { - return builder("TryStatement", ...arguments); + return builder.apply("TryStatement", arguments); } export function unaryExpression( operator: "void" | "throw" | "delete" | "!" | "+" | "-" | "~" | "typeof", argument: t.Expression, prefix?: boolean, ): t.UnaryExpression { - return builder("UnaryExpression", ...arguments); + return builder.apply("UnaryExpression", arguments); } export function updateExpression( operator: "++" | "--", argument: t.Expression, prefix?: boolean, ): t.UpdateExpression { - return builder("UpdateExpression", ...arguments); + return builder.apply("UpdateExpression", arguments); } export function variableDeclaration( kind: "var" | "let" | "const", declarations: Array, ): t.VariableDeclaration { - return builder("VariableDeclaration", ...arguments); + return builder.apply("VariableDeclaration", arguments); } export function variableDeclarator( id: t.LVal, init?: t.Expression | null, ): t.VariableDeclarator { - return builder("VariableDeclarator", ...arguments); + return builder.apply("VariableDeclarator", arguments); } export function whileStatement( test: t.Expression, body: t.Statement, ): t.WhileStatement { - return builder("WhileStatement", ...arguments); + return builder.apply("WhileStatement", arguments); } export function withStatement( object: t.Expression, body: t.Statement, ): t.WithStatement { - return builder("WithStatement", ...arguments); + return builder.apply("WithStatement", arguments); } export function assignmentPattern( left: t.Identifier | t.ObjectPattern | t.ArrayPattern | t.MemberExpression, right: t.Expression, ): t.AssignmentPattern { - return builder("AssignmentPattern", ...arguments); + return builder.apply("AssignmentPattern", arguments); } export function arrayPattern( elements: Array, ): t.ArrayPattern { - return builder("ArrayPattern", ...arguments); + return builder.apply("ArrayPattern", arguments); } export function arrowFunctionExpression( params: Array, body: t.BlockStatement | t.Expression, async?: boolean, ): t.ArrowFunctionExpression { - return builder("ArrowFunctionExpression", ...arguments); + return builder.apply("ArrowFunctionExpression", arguments); } export function classBody( body: Array< @@ -348,7 +348,7 @@ export function classBody( | t.TSIndexSignature >, ): t.ClassBody { - return builder("ClassBody", ...arguments); + return builder.apply("ClassBody", arguments); } export function classExpression( id: t.Identifier | null | undefined, @@ -356,7 +356,7 @@ export function classExpression( body: t.ClassBody, decorators?: Array | null, ): t.ClassExpression { - return builder("ClassExpression", ...arguments); + return builder.apply("ClassExpression", arguments); } export function classDeclaration( id: t.Identifier, @@ -364,12 +364,12 @@ export function classDeclaration( body: t.ClassBody, decorators?: Array | null, ): t.ClassDeclaration { - return builder("ClassDeclaration", ...arguments); + return builder.apply("ClassDeclaration", arguments); } export function exportAllDeclaration( source: t.StringLiteral, ): t.ExportAllDeclaration { - return builder("ExportAllDeclaration", ...arguments); + return builder.apply("ExportAllDeclaration", arguments); } export function exportDefaultDeclaration( declaration: @@ -378,7 +378,7 @@ export function exportDefaultDeclaration( | t.ClassDeclaration | t.Expression, ): t.ExportDefaultDeclaration { - return builder("ExportDefaultDeclaration", ...arguments); + return builder.apply("ExportDefaultDeclaration", arguments); } export function exportNamedDeclaration( declaration?: t.Declaration | null, @@ -387,13 +387,13 @@ export function exportNamedDeclaration( >, source?: t.StringLiteral | null, ): t.ExportNamedDeclaration { - return builder("ExportNamedDeclaration", ...arguments); + return builder.apply("ExportNamedDeclaration", arguments); } export function exportSpecifier( local: t.Identifier, exported: t.Identifier | t.StringLiteral, ): t.ExportSpecifier { - return builder("ExportSpecifier", ...arguments); + return builder.apply("ExportSpecifier", arguments); } export function forOfStatement( left: t.VariableDeclaration | t.LVal, @@ -401,7 +401,7 @@ export function forOfStatement( body: t.Statement, _await?: boolean, ): t.ForOfStatement { - return builder("ForOfStatement", ...arguments); + return builder.apply("ForOfStatement", arguments); } export function importDeclaration( specifiers: Array< @@ -409,29 +409,29 @@ export function importDeclaration( >, source: t.StringLiteral, ): t.ImportDeclaration { - return builder("ImportDeclaration", ...arguments); + return builder.apply("ImportDeclaration", arguments); } export function importDefaultSpecifier( local: t.Identifier, ): t.ImportDefaultSpecifier { - return builder("ImportDefaultSpecifier", ...arguments); + return builder.apply("ImportDefaultSpecifier", arguments); } export function importNamespaceSpecifier( local: t.Identifier, ): t.ImportNamespaceSpecifier { - return builder("ImportNamespaceSpecifier", ...arguments); + return builder.apply("ImportNamespaceSpecifier", arguments); } export function importSpecifier( local: t.Identifier, imported: t.Identifier | t.StringLiteral, ): t.ImportSpecifier { - return builder("ImportSpecifier", ...arguments); + return builder.apply("ImportSpecifier", arguments); } export function metaProperty( meta: t.Identifier, property: t.Identifier, ): t.MetaProperty { - return builder("MetaProperty", ...arguments); + return builder.apply("MetaProperty", arguments); } export function classMethod( kind: "get" | "set" | "method" | "constructor" | undefined, @@ -445,58 +445,58 @@ export function classMethod( generator?: boolean, async?: boolean, ): t.ClassMethod { - return builder("ClassMethod", ...arguments); + return builder.apply("ClassMethod", arguments); } export function objectPattern( properties: Array, ): t.ObjectPattern { - return builder("ObjectPattern", ...arguments); + return builder.apply("ObjectPattern", arguments); } export function spreadElement(argument: t.Expression): t.SpreadElement { - return builder("SpreadElement", ...arguments); + return builder.apply("SpreadElement", arguments); } function _super(): t.Super { - return builder("Super", ...arguments); + return builder.apply("Super", arguments); } export { _super as super }; export function taggedTemplateExpression( tag: t.Expression, quasi: t.TemplateLiteral, ): t.TaggedTemplateExpression { - return builder("TaggedTemplateExpression", ...arguments); + return builder.apply("TaggedTemplateExpression", arguments); } export function templateElement( value: { raw: string; cooked?: string }, tail?: boolean, ): t.TemplateElement { - return builder("TemplateElement", ...arguments); + return builder.apply("TemplateElement", arguments); } export function templateLiteral( quasis: Array, expressions: Array, ): t.TemplateLiteral { - return builder("TemplateLiteral", ...arguments); + return builder.apply("TemplateLiteral", arguments); } export function yieldExpression( argument?: t.Expression | null, delegate?: boolean, ): t.YieldExpression { - return builder("YieldExpression", ...arguments); + return builder.apply("YieldExpression", arguments); } export function awaitExpression(argument: t.Expression): t.AwaitExpression { - return builder("AwaitExpression", ...arguments); + return builder.apply("AwaitExpression", arguments); } function _import(): t.Import { - return builder("Import", ...arguments); + return builder.apply("Import", arguments); } export { _import as import }; export function bigIntLiteral(value: string): t.BigIntLiteral { - return builder("BigIntLiteral", ...arguments); + return builder.apply("BigIntLiteral", arguments); } export function exportNamespaceSpecifier( exported: t.Identifier, ): t.ExportNamespaceSpecifier { - return builder("ExportNamespaceSpecifier", ...arguments); + return builder.apply("ExportNamespaceSpecifier", arguments); } export function optionalMemberExpression( object: t.Expression, @@ -504,7 +504,7 @@ export function optionalMemberExpression( computed: boolean | undefined, optional: boolean, ): t.OptionalMemberExpression { - return builder("OptionalMemberExpression", ...arguments); + return builder.apply("OptionalMemberExpression", arguments); } export function optionalCallExpression( callee: t.Expression, @@ -513,7 +513,7 @@ export function optionalCallExpression( >, optional: boolean, ): t.OptionalCallExpression { - return builder("OptionalCallExpression", ...arguments); + return builder.apply("OptionalCallExpression", arguments); } export function classProperty( key: t.Identifier | t.StringLiteral | t.NumericLiteral | t.Expression, @@ -523,7 +523,7 @@ export function classProperty( computed?: boolean, _static?: boolean, ): t.ClassProperty { - return builder("ClassProperty", ...arguments); + return builder.apply("ClassProperty", arguments); } export function classPrivateProperty( key: t.PrivateName, @@ -531,7 +531,7 @@ export function classPrivateProperty( decorators: Array | null | undefined, _static: any, ): t.ClassPrivateProperty { - return builder("ClassPrivateProperty", ...arguments); + return builder.apply("ClassPrivateProperty", arguments); } export function classPrivateMethod( kind: "get" | "set" | "method" | "constructor" | undefined, @@ -542,38 +542,38 @@ export function classPrivateMethod( body: t.BlockStatement, _static?: boolean, ): t.ClassPrivateMethod { - return builder("ClassPrivateMethod", ...arguments); + return builder.apply("ClassPrivateMethod", arguments); } export function privateName(id: t.Identifier): t.PrivateName { - return builder("PrivateName", ...arguments); + return builder.apply("PrivateName", arguments); } export function staticBlock(body: Array): t.StaticBlock { - return builder("StaticBlock", ...arguments); + return builder.apply("StaticBlock", arguments); } export function anyTypeAnnotation(): t.AnyTypeAnnotation { - return builder("AnyTypeAnnotation", ...arguments); + return builder.apply("AnyTypeAnnotation", arguments); } export function arrayTypeAnnotation( elementType: t.FlowType, ): t.ArrayTypeAnnotation { - return builder("ArrayTypeAnnotation", ...arguments); + return builder.apply("ArrayTypeAnnotation", arguments); } export function booleanTypeAnnotation(): t.BooleanTypeAnnotation { - return builder("BooleanTypeAnnotation", ...arguments); + return builder.apply("BooleanTypeAnnotation", arguments); } export function booleanLiteralTypeAnnotation( value: boolean, ): t.BooleanLiteralTypeAnnotation { - return builder("BooleanLiteralTypeAnnotation", ...arguments); + return builder.apply("BooleanLiteralTypeAnnotation", arguments); } export function nullLiteralTypeAnnotation(): t.NullLiteralTypeAnnotation { - return builder("NullLiteralTypeAnnotation", ...arguments); + return builder.apply("NullLiteralTypeAnnotation", arguments); } export function classImplements( id: t.Identifier, typeParameters?: t.TypeParameterInstantiation | null, ): t.ClassImplements { - return builder("ClassImplements", ...arguments); + return builder.apply("ClassImplements", arguments); } export function declareClass( id: t.Identifier, @@ -581,10 +581,10 @@ export function declareClass( _extends: Array | null | undefined, body: t.ObjectTypeAnnotation, ): t.DeclareClass { - return builder("DeclareClass", ...arguments); + return builder.apply("DeclareClass", arguments); } export function declareFunction(id: t.Identifier): t.DeclareFunction { - return builder("DeclareFunction", ...arguments); + return builder.apply("DeclareFunction", arguments); } export function declareInterface( id: t.Identifier, @@ -592,54 +592,54 @@ export function declareInterface( _extends: Array | null | undefined, body: t.ObjectTypeAnnotation, ): t.DeclareInterface { - return builder("DeclareInterface", ...arguments); + return builder.apply("DeclareInterface", arguments); } export function declareModule( id: t.Identifier | t.StringLiteral, body: t.BlockStatement, kind?: "CommonJS" | "ES" | null, ): t.DeclareModule { - return builder("DeclareModule", ...arguments); + return builder.apply("DeclareModule", arguments); } export function declareModuleExports( typeAnnotation: t.TypeAnnotation, ): t.DeclareModuleExports { - return builder("DeclareModuleExports", ...arguments); + return builder.apply("DeclareModuleExports", arguments); } export function declareTypeAlias( id: t.Identifier, typeParameters: t.TypeParameterDeclaration | null | undefined, right: t.FlowType, ): t.DeclareTypeAlias { - return builder("DeclareTypeAlias", ...arguments); + return builder.apply("DeclareTypeAlias", arguments); } export function declareOpaqueType( id: t.Identifier, typeParameters?: t.TypeParameterDeclaration | null, supertype?: t.FlowType | null, ): t.DeclareOpaqueType { - return builder("DeclareOpaqueType", ...arguments); + return builder.apply("DeclareOpaqueType", arguments); } export function declareVariable(id: t.Identifier): t.DeclareVariable { - return builder("DeclareVariable", ...arguments); + return builder.apply("DeclareVariable", arguments); } export function declareExportDeclaration( declaration?: t.Flow | null, specifiers?: Array | null, source?: t.StringLiteral | null, ): t.DeclareExportDeclaration { - return builder("DeclareExportDeclaration", ...arguments); + return builder.apply("DeclareExportDeclaration", arguments); } export function declareExportAllDeclaration( source: t.StringLiteral, ): t.DeclareExportAllDeclaration { - return builder("DeclareExportAllDeclaration", ...arguments); + return builder.apply("DeclareExportAllDeclaration", arguments); } export function declaredPredicate(value: t.Flow): t.DeclaredPredicate { - return builder("DeclaredPredicate", ...arguments); + return builder.apply("DeclaredPredicate", arguments); } export function existsTypeAnnotation(): t.ExistsTypeAnnotation { - return builder("ExistsTypeAnnotation", ...arguments); + return builder.apply("ExistsTypeAnnotation", arguments); } export function functionTypeAnnotation( typeParameters: t.TypeParameterDeclaration | null | undefined, @@ -647,28 +647,28 @@ export function functionTypeAnnotation( rest: t.FunctionTypeParam | null | undefined, returnType: t.FlowType, ): t.FunctionTypeAnnotation { - return builder("FunctionTypeAnnotation", ...arguments); + return builder.apply("FunctionTypeAnnotation", arguments); } export function functionTypeParam( name: t.Identifier | null | undefined, typeAnnotation: t.FlowType, ): t.FunctionTypeParam { - return builder("FunctionTypeParam", ...arguments); + return builder.apply("FunctionTypeParam", arguments); } export function genericTypeAnnotation( id: t.Identifier | t.QualifiedTypeIdentifier, typeParameters?: t.TypeParameterInstantiation | null, ): t.GenericTypeAnnotation { - return builder("GenericTypeAnnotation", ...arguments); + return builder.apply("GenericTypeAnnotation", arguments); } export function inferredPredicate(): t.InferredPredicate { - return builder("InferredPredicate", ...arguments); + return builder.apply("InferredPredicate", arguments); } export function interfaceExtends( id: t.Identifier | t.QualifiedTypeIdentifier, typeParameters?: t.TypeParameterInstantiation | null, ): t.InterfaceExtends { - return builder("InterfaceExtends", ...arguments); + return builder.apply("InterfaceExtends", arguments); } export function interfaceDeclaration( id: t.Identifier, @@ -676,37 +676,37 @@ export function interfaceDeclaration( _extends: Array | null | undefined, body: t.ObjectTypeAnnotation, ): t.InterfaceDeclaration { - return builder("InterfaceDeclaration", ...arguments); + return builder.apply("InterfaceDeclaration", arguments); } export function interfaceTypeAnnotation( _extends: Array | null | undefined, body: t.ObjectTypeAnnotation, ): t.InterfaceTypeAnnotation { - return builder("InterfaceTypeAnnotation", ...arguments); + return builder.apply("InterfaceTypeAnnotation", arguments); } export function intersectionTypeAnnotation( types: Array, ): t.IntersectionTypeAnnotation { - return builder("IntersectionTypeAnnotation", ...arguments); + return builder.apply("IntersectionTypeAnnotation", arguments); } export function mixedTypeAnnotation(): t.MixedTypeAnnotation { - return builder("MixedTypeAnnotation", ...arguments); + return builder.apply("MixedTypeAnnotation", arguments); } export function emptyTypeAnnotation(): t.EmptyTypeAnnotation { - return builder("EmptyTypeAnnotation", ...arguments); + return builder.apply("EmptyTypeAnnotation", arguments); } export function nullableTypeAnnotation( typeAnnotation: t.FlowType, ): t.NullableTypeAnnotation { - return builder("NullableTypeAnnotation", ...arguments); + return builder.apply("NullableTypeAnnotation", arguments); } export function numberLiteralTypeAnnotation( value: number, ): t.NumberLiteralTypeAnnotation { - return builder("NumberLiteralTypeAnnotation", ...arguments); + return builder.apply("NumberLiteralTypeAnnotation", arguments); } export function numberTypeAnnotation(): t.NumberTypeAnnotation { - return builder("NumberTypeAnnotation", ...arguments); + return builder.apply("NumberTypeAnnotation", arguments); } export function objectTypeAnnotation( properties: Array, @@ -715,7 +715,7 @@ export function objectTypeAnnotation( internalSlots?: Array | null, exact?: boolean, ): t.ObjectTypeAnnotation { - return builder("ObjectTypeAnnotation", ...arguments); + return builder.apply("ObjectTypeAnnotation", arguments); } export function objectTypeInternalSlot( id: t.Identifier, @@ -724,12 +724,12 @@ export function objectTypeInternalSlot( _static: boolean, method: boolean, ): t.ObjectTypeInternalSlot { - return builder("ObjectTypeInternalSlot", ...arguments); + return builder.apply("ObjectTypeInternalSlot", arguments); } export function objectTypeCallProperty( value: t.FlowType, ): t.ObjectTypeCallProperty { - return builder("ObjectTypeCallProperty", ...arguments); + return builder.apply("ObjectTypeCallProperty", arguments); } export function objectTypeIndexer( id: t.Identifier | null | undefined, @@ -737,19 +737,19 @@ export function objectTypeIndexer( value: t.FlowType, variance?: t.Variance | null, ): t.ObjectTypeIndexer { - return builder("ObjectTypeIndexer", ...arguments); + return builder.apply("ObjectTypeIndexer", arguments); } export function objectTypeProperty( key: t.Identifier | t.StringLiteral, value: t.FlowType, variance?: t.Variance | null, ): t.ObjectTypeProperty { - return builder("ObjectTypeProperty", ...arguments); + return builder.apply("ObjectTypeProperty", arguments); } export function objectTypeSpreadProperty( argument: t.FlowType, ): t.ObjectTypeSpreadProperty { - return builder("ObjectTypeSpreadProperty", ...arguments); + return builder.apply("ObjectTypeSpreadProperty", arguments); } export function opaqueType( id: t.Identifier, @@ -757,81 +757,81 @@ export function opaqueType( supertype: t.FlowType | null | undefined, impltype: t.FlowType, ): t.OpaqueType { - return builder("OpaqueType", ...arguments); + return builder.apply("OpaqueType", arguments); } export function qualifiedTypeIdentifier( id: t.Identifier, qualification: t.Identifier | t.QualifiedTypeIdentifier, ): t.QualifiedTypeIdentifier { - return builder("QualifiedTypeIdentifier", ...arguments); + return builder.apply("QualifiedTypeIdentifier", arguments); } export function stringLiteralTypeAnnotation( value: string, ): t.StringLiteralTypeAnnotation { - return builder("StringLiteralTypeAnnotation", ...arguments); + return builder.apply("StringLiteralTypeAnnotation", arguments); } export function stringTypeAnnotation(): t.StringTypeAnnotation { - return builder("StringTypeAnnotation", ...arguments); + return builder.apply("StringTypeAnnotation", arguments); } export function symbolTypeAnnotation(): t.SymbolTypeAnnotation { - return builder("SymbolTypeAnnotation", ...arguments); + return builder.apply("SymbolTypeAnnotation", arguments); } export function thisTypeAnnotation(): t.ThisTypeAnnotation { - return builder("ThisTypeAnnotation", ...arguments); + return builder.apply("ThisTypeAnnotation", arguments); } export function tupleTypeAnnotation( types: Array, ): t.TupleTypeAnnotation { - return builder("TupleTypeAnnotation", ...arguments); + return builder.apply("TupleTypeAnnotation", arguments); } export function typeofTypeAnnotation( argument: t.FlowType, ): t.TypeofTypeAnnotation { - return builder("TypeofTypeAnnotation", ...arguments); + return builder.apply("TypeofTypeAnnotation", arguments); } export function typeAlias( id: t.Identifier, typeParameters: t.TypeParameterDeclaration | null | undefined, right: t.FlowType, ): t.TypeAlias { - return builder("TypeAlias", ...arguments); + return builder.apply("TypeAlias", arguments); } export function typeAnnotation(typeAnnotation: t.FlowType): t.TypeAnnotation { - return builder("TypeAnnotation", ...arguments); + return builder.apply("TypeAnnotation", arguments); } export function typeCastExpression( expression: t.Expression, typeAnnotation: t.TypeAnnotation, ): t.TypeCastExpression { - return builder("TypeCastExpression", ...arguments); + return builder.apply("TypeCastExpression", arguments); } export function typeParameter( bound?: t.TypeAnnotation | null, _default?: t.FlowType | null, variance?: t.Variance | null, ): t.TypeParameter { - return builder("TypeParameter", ...arguments); + return builder.apply("TypeParameter", arguments); } export function typeParameterDeclaration( params: Array, ): t.TypeParameterDeclaration { - return builder("TypeParameterDeclaration", ...arguments); + return builder.apply("TypeParameterDeclaration", arguments); } export function typeParameterInstantiation( params: Array, ): t.TypeParameterInstantiation { - return builder("TypeParameterInstantiation", ...arguments); + return builder.apply("TypeParameterInstantiation", arguments); } export function unionTypeAnnotation( types: Array, ): t.UnionTypeAnnotation { - return builder("UnionTypeAnnotation", ...arguments); + return builder.apply("UnionTypeAnnotation", arguments); } export function variance(kind: "minus" | "plus"): t.Variance { - return builder("Variance", ...arguments); + return builder.apply("Variance", arguments); } export function voidTypeAnnotation(): t.VoidTypeAnnotation { - return builder("VoidTypeAnnotation", ...arguments); + return builder.apply("VoidTypeAnnotation", arguments); } export function enumDeclaration( id: t.Identifier, @@ -841,57 +841,57 @@ export function enumDeclaration( | t.EnumStringBody | t.EnumSymbolBody, ): t.EnumDeclaration { - return builder("EnumDeclaration", ...arguments); + return builder.apply("EnumDeclaration", arguments); } export function enumBooleanBody( members: Array, ): t.EnumBooleanBody { - return builder("EnumBooleanBody", ...arguments); + return builder.apply("EnumBooleanBody", arguments); } export function enumNumberBody( members: Array, ): t.EnumNumberBody { - return builder("EnumNumberBody", ...arguments); + return builder.apply("EnumNumberBody", arguments); } export function enumStringBody( members: Array, ): t.EnumStringBody { - return builder("EnumStringBody", ...arguments); + return builder.apply("EnumStringBody", arguments); } export function enumSymbolBody( members: Array, ): t.EnumSymbolBody { - return builder("EnumSymbolBody", ...arguments); + return builder.apply("EnumSymbolBody", arguments); } export function enumBooleanMember(id: t.Identifier): t.EnumBooleanMember { - return builder("EnumBooleanMember", ...arguments); + return builder.apply("EnumBooleanMember", arguments); } export function enumNumberMember( id: t.Identifier, init: t.NumericLiteral, ): t.EnumNumberMember { - return builder("EnumNumberMember", ...arguments); + return builder.apply("EnumNumberMember", arguments); } export function enumStringMember( id: t.Identifier, init: t.StringLiteral, ): t.EnumStringMember { - return builder("EnumStringMember", ...arguments); + return builder.apply("EnumStringMember", arguments); } export function enumDefaultedMember(id: t.Identifier): t.EnumDefaultedMember { - return builder("EnumDefaultedMember", ...arguments); + return builder.apply("EnumDefaultedMember", arguments); } export function indexedAccessType( objectType: t.FlowType, indexType: t.FlowType, ): t.IndexedAccessType { - return builder("IndexedAccessType", ...arguments); + return builder.apply("IndexedAccessType", arguments); } export function optionalIndexedAccessType( objectType: t.FlowType, indexType: t.FlowType, ): t.OptionalIndexedAccessType { - return builder("OptionalIndexedAccessType", ...arguments); + return builder.apply("OptionalIndexedAccessType", arguments); } export function jsxAttribute( name: t.JSXIdentifier | t.JSXNamespacedName, @@ -902,13 +902,13 @@ export function jsxAttribute( | t.JSXExpressionContainer | null, ): t.JSXAttribute { - return builder("JSXAttribute", ...arguments); + return builder.apply("JSXAttribute", arguments); } export { jsxAttribute as jSXAttribute }; export function jsxClosingElement( name: t.JSXIdentifier | t.JSXMemberExpression | t.JSXNamespacedName, ): t.JSXClosingElement { - return builder("JSXClosingElement", ...arguments); + return builder.apply("JSXClosingElement", arguments); } export { jsxClosingElement as jSXClosingElement }; export function jsxElement( @@ -923,39 +923,39 @@ export function jsxElement( >, selfClosing?: boolean | null, ): t.JSXElement { - return builder("JSXElement", ...arguments); + return builder.apply("JSXElement", arguments); } export { jsxElement as jSXElement }; export function jsxEmptyExpression(): t.JSXEmptyExpression { - return builder("JSXEmptyExpression", ...arguments); + return builder.apply("JSXEmptyExpression", arguments); } export { jsxEmptyExpression as jSXEmptyExpression }; export function jsxExpressionContainer( expression: t.Expression | t.JSXEmptyExpression, ): t.JSXExpressionContainer { - return builder("JSXExpressionContainer", ...arguments); + return builder.apply("JSXExpressionContainer", arguments); } export { jsxExpressionContainer as jSXExpressionContainer }; export function jsxSpreadChild(expression: t.Expression): t.JSXSpreadChild { - return builder("JSXSpreadChild", ...arguments); + return builder.apply("JSXSpreadChild", arguments); } export { jsxSpreadChild as jSXSpreadChild }; export function jsxIdentifier(name: string): t.JSXIdentifier { - return builder("JSXIdentifier", ...arguments); + return builder.apply("JSXIdentifier", arguments); } export { jsxIdentifier as jSXIdentifier }; export function jsxMemberExpression( object: t.JSXMemberExpression | t.JSXIdentifier, property: t.JSXIdentifier, ): t.JSXMemberExpression { - return builder("JSXMemberExpression", ...arguments); + return builder.apply("JSXMemberExpression", arguments); } export { jsxMemberExpression as jSXMemberExpression }; export function jsxNamespacedName( namespace: t.JSXIdentifier, name: t.JSXIdentifier, ): t.JSXNamespacedName { - return builder("JSXNamespacedName", ...arguments); + return builder.apply("JSXNamespacedName", arguments); } export { jsxNamespacedName as jSXNamespacedName }; export function jsxOpeningElement( @@ -963,17 +963,17 @@ export function jsxOpeningElement( attributes: Array, selfClosing?: boolean, ): t.JSXOpeningElement { - return builder("JSXOpeningElement", ...arguments); + return builder.apply("JSXOpeningElement", arguments); } export { jsxOpeningElement as jSXOpeningElement }; export function jsxSpreadAttribute( argument: t.Expression, ): t.JSXSpreadAttribute { - return builder("JSXSpreadAttribute", ...arguments); + return builder.apply("JSXSpreadAttribute", arguments); } export { jsxSpreadAttribute as jSXSpreadAttribute }; export function jsxText(value: string): t.JSXText { - return builder("JSXText", ...arguments); + return builder.apply("JSXText", arguments); } export { jsxText as jSXText }; export function jsxFragment( @@ -987,19 +987,19 @@ export function jsxFragment( | t.JSXFragment >, ): t.JSXFragment { - return builder("JSXFragment", ...arguments); + return builder.apply("JSXFragment", arguments); } export { jsxFragment as jSXFragment }; export function jsxOpeningFragment(): t.JSXOpeningFragment { - return builder("JSXOpeningFragment", ...arguments); + return builder.apply("JSXOpeningFragment", arguments); } export { jsxOpeningFragment as jSXOpeningFragment }; export function jsxClosingFragment(): t.JSXClosingFragment { - return builder("JSXClosingFragment", ...arguments); + return builder.apply("JSXClosingFragment", arguments); } export { jsxClosingFragment as jSXClosingFragment }; export function noop(): t.Noop { - return builder("Noop", ...arguments); + return builder.apply("Noop", arguments); } export function placeholder( expectedNode: @@ -1013,76 +1013,76 @@ export function placeholder( | "Pattern", name: t.Identifier, ): t.Placeholder { - return builder("Placeholder", ...arguments); + return builder.apply("Placeholder", arguments); } export function v8IntrinsicIdentifier(name: string): t.V8IntrinsicIdentifier { - return builder("V8IntrinsicIdentifier", ...arguments); + return builder.apply("V8IntrinsicIdentifier", arguments); } export function argumentPlaceholder(): t.ArgumentPlaceholder { - return builder("ArgumentPlaceholder", ...arguments); + return builder.apply("ArgumentPlaceholder", arguments); } export function bindExpression( object: t.Expression, callee: t.Expression, ): t.BindExpression { - return builder("BindExpression", ...arguments); + return builder.apply("BindExpression", arguments); } export function importAttribute( key: t.Identifier | t.StringLiteral, value: t.StringLiteral, ): t.ImportAttribute { - return builder("ImportAttribute", ...arguments); + return builder.apply("ImportAttribute", arguments); } export function decorator(expression: t.Expression): t.Decorator { - return builder("Decorator", ...arguments); + return builder.apply("Decorator", arguments); } export function doExpression( body: t.BlockStatement, async?: boolean, ): t.DoExpression { - return builder("DoExpression", ...arguments); + return builder.apply("DoExpression", arguments); } export function exportDefaultSpecifier( exported: t.Identifier, ): t.ExportDefaultSpecifier { - return builder("ExportDefaultSpecifier", ...arguments); + return builder.apply("ExportDefaultSpecifier", arguments); } export function recordExpression( properties: Array, ): t.RecordExpression { - return builder("RecordExpression", ...arguments); + return builder.apply("RecordExpression", arguments); } export function tupleExpression( elements?: Array, ): t.TupleExpression { - return builder("TupleExpression", ...arguments); + return builder.apply("TupleExpression", arguments); } export function decimalLiteral(value: string): t.DecimalLiteral { - return builder("DecimalLiteral", ...arguments); + return builder.apply("DecimalLiteral", arguments); } export function moduleExpression(body: t.Program): t.ModuleExpression { - return builder("ModuleExpression", ...arguments); + return builder.apply("ModuleExpression", arguments); } export function topicReference(): t.TopicReference { - return builder("TopicReference", ...arguments); + return builder.apply("TopicReference", arguments); } export function pipelineTopicExpression( expression: t.Expression, ): t.PipelineTopicExpression { - return builder("PipelineTopicExpression", ...arguments); + return builder.apply("PipelineTopicExpression", arguments); } export function pipelineBareFunction( callee: t.Expression, ): t.PipelineBareFunction { - return builder("PipelineBareFunction", ...arguments); + return builder.apply("PipelineBareFunction", arguments); } export function pipelinePrimaryTopicReference(): t.PipelinePrimaryTopicReference { - return builder("PipelinePrimaryTopicReference", ...arguments); + return builder.apply("PipelinePrimaryTopicReference", arguments); } export function tsParameterProperty( parameter: t.Identifier | t.AssignmentPattern, ): t.TSParameterProperty { - return builder("TSParameterProperty", ...arguments); + return builder.apply("TSParameterProperty", arguments); } export { tsParameterProperty as tSParameterProperty }; export function tsDeclareFunction( @@ -1091,7 +1091,7 @@ export function tsDeclareFunction( params: Array, returnType?: t.TSTypeAnnotation | t.Noop | null, ): t.TSDeclareFunction { - return builder("TSDeclareFunction", ...arguments); + return builder.apply("TSDeclareFunction", arguments); } export { tsDeclareFunction as tSDeclareFunction }; export function tsDeclareMethod( @@ -1103,14 +1103,14 @@ export function tsDeclareMethod( >, returnType?: t.TSTypeAnnotation | t.Noop | null, ): t.TSDeclareMethod { - return builder("TSDeclareMethod", ...arguments); + return builder.apply("TSDeclareMethod", arguments); } export { tsDeclareMethod as tSDeclareMethod }; export function tsQualifiedName( left: t.TSEntityName, right: t.Identifier, ): t.TSQualifiedName { - return builder("TSQualifiedName", ...arguments); + return builder.apply("TSQualifiedName", arguments); } export { tsQualifiedName as tSQualifiedName }; export function tsCallSignatureDeclaration( @@ -1118,7 +1118,7 @@ export function tsCallSignatureDeclaration( parameters: Array, typeAnnotation?: t.TSTypeAnnotation | null, ): t.TSCallSignatureDeclaration { - return builder("TSCallSignatureDeclaration", ...arguments); + return builder.apply("TSCallSignatureDeclaration", arguments); } export { tsCallSignatureDeclaration as tSCallSignatureDeclaration }; export function tsConstructSignatureDeclaration( @@ -1126,7 +1126,7 @@ export function tsConstructSignatureDeclaration( parameters: Array, typeAnnotation?: t.TSTypeAnnotation | null, ): t.TSConstructSignatureDeclaration { - return builder("TSConstructSignatureDeclaration", ...arguments); + return builder.apply("TSConstructSignatureDeclaration", arguments); } export { tsConstructSignatureDeclaration as tSConstructSignatureDeclaration }; export function tsPropertySignature( @@ -1134,7 +1134,7 @@ export function tsPropertySignature( typeAnnotation?: t.TSTypeAnnotation | null, initializer?: t.Expression | null, ): t.TSPropertySignature { - return builder("TSPropertySignature", ...arguments); + return builder.apply("TSPropertySignature", arguments); } export { tsPropertySignature as tSPropertySignature }; export function tsMethodSignature( @@ -1143,70 +1143,70 @@ export function tsMethodSignature( parameters: Array, typeAnnotation?: t.TSTypeAnnotation | null, ): t.TSMethodSignature { - return builder("TSMethodSignature", ...arguments); + return builder.apply("TSMethodSignature", arguments); } export { tsMethodSignature as tSMethodSignature }; export function tsIndexSignature( parameters: Array, typeAnnotation?: t.TSTypeAnnotation | null, ): t.TSIndexSignature { - return builder("TSIndexSignature", ...arguments); + return builder.apply("TSIndexSignature", arguments); } export { tsIndexSignature as tSIndexSignature }; export function tsAnyKeyword(): t.TSAnyKeyword { - return builder("TSAnyKeyword", ...arguments); + return builder.apply("TSAnyKeyword", arguments); } export { tsAnyKeyword as tSAnyKeyword }; export function tsBooleanKeyword(): t.TSBooleanKeyword { - return builder("TSBooleanKeyword", ...arguments); + return builder.apply("TSBooleanKeyword", arguments); } export { tsBooleanKeyword as tSBooleanKeyword }; export function tsBigIntKeyword(): t.TSBigIntKeyword { - return builder("TSBigIntKeyword", ...arguments); + return builder.apply("TSBigIntKeyword", arguments); } export { tsBigIntKeyword as tSBigIntKeyword }; export function tsIntrinsicKeyword(): t.TSIntrinsicKeyword { - return builder("TSIntrinsicKeyword", ...arguments); + return builder.apply("TSIntrinsicKeyword", arguments); } export { tsIntrinsicKeyword as tSIntrinsicKeyword }; export function tsNeverKeyword(): t.TSNeverKeyword { - return builder("TSNeverKeyword", ...arguments); + return builder.apply("TSNeverKeyword", arguments); } export { tsNeverKeyword as tSNeverKeyword }; export function tsNullKeyword(): t.TSNullKeyword { - return builder("TSNullKeyword", ...arguments); + return builder.apply("TSNullKeyword", arguments); } export { tsNullKeyword as tSNullKeyword }; export function tsNumberKeyword(): t.TSNumberKeyword { - return builder("TSNumberKeyword", ...arguments); + return builder.apply("TSNumberKeyword", arguments); } export { tsNumberKeyword as tSNumberKeyword }; export function tsObjectKeyword(): t.TSObjectKeyword { - return builder("TSObjectKeyword", ...arguments); + return builder.apply("TSObjectKeyword", arguments); } export { tsObjectKeyword as tSObjectKeyword }; export function tsStringKeyword(): t.TSStringKeyword { - return builder("TSStringKeyword", ...arguments); + return builder.apply("TSStringKeyword", arguments); } export { tsStringKeyword as tSStringKeyword }; export function tsSymbolKeyword(): t.TSSymbolKeyword { - return builder("TSSymbolKeyword", ...arguments); + return builder.apply("TSSymbolKeyword", arguments); } export { tsSymbolKeyword as tSSymbolKeyword }; export function tsUndefinedKeyword(): t.TSUndefinedKeyword { - return builder("TSUndefinedKeyword", ...arguments); + return builder.apply("TSUndefinedKeyword", arguments); } export { tsUndefinedKeyword as tSUndefinedKeyword }; export function tsUnknownKeyword(): t.TSUnknownKeyword { - return builder("TSUnknownKeyword", ...arguments); + return builder.apply("TSUnknownKeyword", arguments); } export { tsUnknownKeyword as tSUnknownKeyword }; export function tsVoidKeyword(): t.TSVoidKeyword { - return builder("TSVoidKeyword", ...arguments); + return builder.apply("TSVoidKeyword", arguments); } export { tsVoidKeyword as tSVoidKeyword }; export function tsThisType(): t.TSThisType { - return builder("TSThisType", ...arguments); + return builder.apply("TSThisType", arguments); } export { tsThisType as tSThisType }; export function tsFunctionType( @@ -1214,7 +1214,7 @@ export function tsFunctionType( parameters: Array, typeAnnotation?: t.TSTypeAnnotation | null, ): t.TSFunctionType { - return builder("TSFunctionType", ...arguments); + return builder.apply("TSFunctionType", arguments); } export { tsFunctionType as tSFunctionType }; export function tsConstructorType( @@ -1222,14 +1222,14 @@ export function tsConstructorType( parameters: Array, typeAnnotation?: t.TSTypeAnnotation | null, ): t.TSConstructorType { - return builder("TSConstructorType", ...arguments); + return builder.apply("TSConstructorType", arguments); } export { tsConstructorType as tSConstructorType }; export function tsTypeReference( typeName: t.TSEntityName, typeParameters?: t.TSTypeParameterInstantiation | null, ): t.TSTypeReference { - return builder("TSTypeReference", ...arguments); + return builder.apply("TSTypeReference", arguments); } export { tsTypeReference as tSTypeReference }; export function tsTypePredicate( @@ -1237,37 +1237,37 @@ export function tsTypePredicate( typeAnnotation?: t.TSTypeAnnotation | null, asserts?: boolean | null, ): t.TSTypePredicate { - return builder("TSTypePredicate", ...arguments); + return builder.apply("TSTypePredicate", arguments); } export { tsTypePredicate as tSTypePredicate }; export function tsTypeQuery( exprName: t.TSEntityName | t.TSImportType, ): t.TSTypeQuery { - return builder("TSTypeQuery", ...arguments); + return builder.apply("TSTypeQuery", arguments); } export { tsTypeQuery as tSTypeQuery }; export function tsTypeLiteral( members: Array, ): t.TSTypeLiteral { - return builder("TSTypeLiteral", ...arguments); + return builder.apply("TSTypeLiteral", arguments); } export { tsTypeLiteral as tSTypeLiteral }; export function tsArrayType(elementType: t.TSType): t.TSArrayType { - return builder("TSArrayType", ...arguments); + return builder.apply("TSArrayType", arguments); } export { tsArrayType as tSArrayType }; export function tsTupleType( elementTypes: Array, ): t.TSTupleType { - return builder("TSTupleType", ...arguments); + return builder.apply("TSTupleType", arguments); } export { tsTupleType as tSTupleType }; export function tsOptionalType(typeAnnotation: t.TSType): t.TSOptionalType { - return builder("TSOptionalType", ...arguments); + return builder.apply("TSOptionalType", arguments); } export { tsOptionalType as tSOptionalType }; export function tsRestType(typeAnnotation: t.TSType): t.TSRestType { - return builder("TSRestType", ...arguments); + return builder.apply("TSRestType", arguments); } export { tsRestType as tSRestType }; export function tsNamedTupleMember( @@ -1275,17 +1275,17 @@ export function tsNamedTupleMember( elementType: t.TSType, optional?: boolean, ): t.TSNamedTupleMember { - return builder("TSNamedTupleMember", ...arguments); + return builder.apply("TSNamedTupleMember", arguments); } export { tsNamedTupleMember as tSNamedTupleMember }; export function tsUnionType(types: Array): t.TSUnionType { - return builder("TSUnionType", ...arguments); + return builder.apply("TSUnionType", arguments); } export { tsUnionType as tSUnionType }; export function tsIntersectionType( types: Array, ): t.TSIntersectionType { - return builder("TSIntersectionType", ...arguments); + return builder.apply("TSIntersectionType", arguments); } export { tsIntersectionType as tSIntersectionType }; export function tsConditionalType( @@ -1294,28 +1294,28 @@ export function tsConditionalType( trueType: t.TSType, falseType: t.TSType, ): t.TSConditionalType { - return builder("TSConditionalType", ...arguments); + return builder.apply("TSConditionalType", arguments); } export { tsConditionalType as tSConditionalType }; export function tsInferType(typeParameter: t.TSTypeParameter): t.TSInferType { - return builder("TSInferType", ...arguments); + return builder.apply("TSInferType", arguments); } export { tsInferType as tSInferType }; export function tsParenthesizedType( typeAnnotation: t.TSType, ): t.TSParenthesizedType { - return builder("TSParenthesizedType", ...arguments); + return builder.apply("TSParenthesizedType", arguments); } export { tsParenthesizedType as tSParenthesizedType }; export function tsTypeOperator(typeAnnotation: t.TSType): t.TSTypeOperator { - return builder("TSTypeOperator", ...arguments); + return builder.apply("TSTypeOperator", arguments); } export { tsTypeOperator as tSTypeOperator }; export function tsIndexedAccessType( objectType: t.TSType, indexType: t.TSType, ): t.TSIndexedAccessType { - return builder("TSIndexedAccessType", ...arguments); + return builder.apply("TSIndexedAccessType", arguments); } export { tsIndexedAccessType as tSIndexedAccessType }; export function tsMappedType( @@ -1323,7 +1323,7 @@ export function tsMappedType( typeAnnotation?: t.TSType | null, nameType?: t.TSType | null, ): t.TSMappedType { - return builder("TSMappedType", ...arguments); + return builder.apply("TSMappedType", arguments); } export { tsMappedType as tSMappedType }; export function tsLiteralType( @@ -1334,14 +1334,14 @@ export function tsLiteralType( | t.BigIntLiteral | t.UnaryExpression, ): t.TSLiteralType { - return builder("TSLiteralType", ...arguments); + return builder.apply("TSLiteralType", arguments); } export { tsLiteralType as tSLiteralType }; export function tsExpressionWithTypeArguments( expression: t.TSEntityName, typeParameters?: t.TSTypeParameterInstantiation | null, ): t.TSExpressionWithTypeArguments { - return builder("TSExpressionWithTypeArguments", ...arguments); + return builder.apply("TSExpressionWithTypeArguments", arguments); } export { tsExpressionWithTypeArguments as tSExpressionWithTypeArguments }; export function tsInterfaceDeclaration( @@ -1350,13 +1350,13 @@ export function tsInterfaceDeclaration( _extends: Array | null | undefined, body: t.TSInterfaceBody, ): t.TSInterfaceDeclaration { - return builder("TSInterfaceDeclaration", ...arguments); + return builder.apply("TSInterfaceDeclaration", arguments); } export { tsInterfaceDeclaration as tSInterfaceDeclaration }; export function tsInterfaceBody( body: Array, ): t.TSInterfaceBody { - return builder("TSInterfaceBody", ...arguments); + return builder.apply("TSInterfaceBody", arguments); } export { tsInterfaceBody as tSInterfaceBody }; export function tsTypeAliasDeclaration( @@ -1364,46 +1364,46 @@ export function tsTypeAliasDeclaration( typeParameters: t.TSTypeParameterDeclaration | null | undefined, typeAnnotation: t.TSType, ): t.TSTypeAliasDeclaration { - return builder("TSTypeAliasDeclaration", ...arguments); + return builder.apply("TSTypeAliasDeclaration", arguments); } export { tsTypeAliasDeclaration as tSTypeAliasDeclaration }; export function tsAsExpression( expression: t.Expression, typeAnnotation: t.TSType, ): t.TSAsExpression { - return builder("TSAsExpression", ...arguments); + return builder.apply("TSAsExpression", arguments); } export { tsAsExpression as tSAsExpression }; export function tsTypeAssertion( typeAnnotation: t.TSType, expression: t.Expression, ): t.TSTypeAssertion { - return builder("TSTypeAssertion", ...arguments); + return builder.apply("TSTypeAssertion", arguments); } export { tsTypeAssertion as tSTypeAssertion }; export function tsEnumDeclaration( id: t.Identifier, members: Array, ): t.TSEnumDeclaration { - return builder("TSEnumDeclaration", ...arguments); + return builder.apply("TSEnumDeclaration", arguments); } export { tsEnumDeclaration as tSEnumDeclaration }; export function tsEnumMember( id: t.Identifier | t.StringLiteral, initializer?: t.Expression | null, ): t.TSEnumMember { - return builder("TSEnumMember", ...arguments); + return builder.apply("TSEnumMember", arguments); } export { tsEnumMember as tSEnumMember }; export function tsModuleDeclaration( id: t.Identifier | t.StringLiteral, body: t.TSModuleBlock | t.TSModuleDeclaration, ): t.TSModuleDeclaration { - return builder("TSModuleDeclaration", ...arguments); + return builder.apply("TSModuleDeclaration", arguments); } export { tsModuleDeclaration as tSModuleDeclaration }; export function tsModuleBlock(body: Array): t.TSModuleBlock { - return builder("TSModuleBlock", ...arguments); + return builder.apply("TSModuleBlock", arguments); } export { tsModuleBlock as tSModuleBlock }; export function tsImportType( @@ -1411,54 +1411,54 @@ export function tsImportType( qualifier?: t.TSEntityName | null, typeParameters?: t.TSTypeParameterInstantiation | null, ): t.TSImportType { - return builder("TSImportType", ...arguments); + return builder.apply("TSImportType", arguments); } export { tsImportType as tSImportType }; export function tsImportEqualsDeclaration( id: t.Identifier, moduleReference: t.TSEntityName | t.TSExternalModuleReference, ): t.TSImportEqualsDeclaration { - return builder("TSImportEqualsDeclaration", ...arguments); + return builder.apply("TSImportEqualsDeclaration", arguments); } export { tsImportEqualsDeclaration as tSImportEqualsDeclaration }; export function tsExternalModuleReference( expression: t.StringLiteral, ): t.TSExternalModuleReference { - return builder("TSExternalModuleReference", ...arguments); + return builder.apply("TSExternalModuleReference", arguments); } export { tsExternalModuleReference as tSExternalModuleReference }; export function tsNonNullExpression( expression: t.Expression, ): t.TSNonNullExpression { - return builder("TSNonNullExpression", ...arguments); + return builder.apply("TSNonNullExpression", arguments); } export { tsNonNullExpression as tSNonNullExpression }; export function tsExportAssignment( expression: t.Expression, ): t.TSExportAssignment { - return builder("TSExportAssignment", ...arguments); + return builder.apply("TSExportAssignment", arguments); } export { tsExportAssignment as tSExportAssignment }; export function tsNamespaceExportDeclaration( id: t.Identifier, ): t.TSNamespaceExportDeclaration { - return builder("TSNamespaceExportDeclaration", ...arguments); + return builder.apply("TSNamespaceExportDeclaration", arguments); } export { tsNamespaceExportDeclaration as tSNamespaceExportDeclaration }; export function tsTypeAnnotation(typeAnnotation: t.TSType): t.TSTypeAnnotation { - return builder("TSTypeAnnotation", ...arguments); + return builder.apply("TSTypeAnnotation", arguments); } export { tsTypeAnnotation as tSTypeAnnotation }; export function tsTypeParameterInstantiation( params: Array, ): t.TSTypeParameterInstantiation { - return builder("TSTypeParameterInstantiation", ...arguments); + return builder.apply("TSTypeParameterInstantiation", arguments); } export { tsTypeParameterInstantiation as tSTypeParameterInstantiation }; export function tsTypeParameterDeclaration( params: Array, ): t.TSTypeParameterDeclaration { - return builder("TSTypeParameterDeclaration", ...arguments); + return builder.apply("TSTypeParameterDeclaration", arguments); } export { tsTypeParameterDeclaration as tSTypeParameterDeclaration }; export function tsTypeParameter( @@ -1466,7 +1466,7 @@ export function tsTypeParameter( _default: t.TSType | null | undefined, name: string, ): t.TSTypeParameter { - return builder("TSTypeParameter", ...arguments); + return builder.apply("TSTypeParameter", arguments); } export { tsTypeParameter as tSTypeParameter }; /** @deprecated */ @@ -1474,19 +1474,19 @@ function NumberLiteral(...args: Array): any { console.trace( "The node type NumberLiteral has been renamed to NumericLiteral", ); - return builder("NumberLiteral", ...args); + return builder.apply("NumberLiteral", arguments); } export { NumberLiteral as numberLiteral }; /** @deprecated */ function RegexLiteral(...args: Array): any { console.trace("The node type RegexLiteral has been renamed to RegExpLiteral"); - return builder("RegexLiteral", ...args); + return builder.apply("RegexLiteral", arguments); } export { RegexLiteral as regexLiteral }; /** @deprecated */ function RestProperty(...args: Array): any { console.trace("The node type RestProperty has been renamed to RestElement"); - return builder("RestProperty", ...args); + return builder.apply("RestProperty", arguments); } export { RestProperty as restProperty }; /** @deprecated */ @@ -1494,6 +1494,6 @@ function SpreadProperty(...args: Array): any { console.trace( "The node type SpreadProperty has been renamed to SpreadElement", ); - return builder("SpreadProperty", ...args); + return builder.apply("SpreadProperty", arguments); } export { SpreadProperty as spreadProperty }; From 3d67e040fc6ce775c2a4c0e62eb473daaa353a62 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Sat, 16 Oct 2021 13:45:31 +0200 Subject: [PATCH 6/7] improve deprecated builder type signatures (also avoids constructing ...args Array) --- packages/babel-types/scripts/generators/builders.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/babel-types/scripts/generators/builders.js b/packages/babel-types/scripts/generators/builders.js index 6805af49571a..13e772eb43d0 100644 --- a/packages/babel-types/scripts/generators/builders.js +++ b/packages/babel-types/scripts/generators/builders.js @@ -119,7 +119,7 @@ import type * as t from "../.."; const newType = definitions.DEPRECATED_KEYS[type]; const formatedBuilderName = formatBuilderName(type); output += `/** @deprecated */ -function ${type}(...args: Array): any { +function ${type}(${generateBuilderArgs(newType).join(", ")}): t.${type} { console.trace("The node type ${type} has been renamed to ${newType}"); return builder.apply("${type}", arguments); } From 546fe9a407e8c2fae22a6990c0f50d2fd6659792 Mon Sep 17 00:00:00 2001 From: Mickey Rose Date: Sat, 16 Oct 2021 13:48:03 +0200 Subject: [PATCH 7/7] chore: gulp generate-type-helpers --- packages/babel-types/src/builders/generated/index.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/babel-types/src/builders/generated/index.ts b/packages/babel-types/src/builders/generated/index.ts index 6b2704fadabe..a59d1301e976 100755 --- a/packages/babel-types/src/builders/generated/index.ts +++ b/packages/babel-types/src/builders/generated/index.ts @@ -1470,7 +1470,7 @@ export function tsTypeParameter( } export { tsTypeParameter as tSTypeParameter }; /** @deprecated */ -function NumberLiteral(...args: Array): any { +function NumberLiteral(value: number): t.NumberLiteral { console.trace( "The node type NumberLiteral has been renamed to NumericLiteral", ); @@ -1478,19 +1478,19 @@ function NumberLiteral(...args: Array): any { } export { NumberLiteral as numberLiteral }; /** @deprecated */ -function RegexLiteral(...args: Array): any { +function RegexLiteral(pattern: string, flags?: string): t.RegexLiteral { console.trace("The node type RegexLiteral has been renamed to RegExpLiteral"); return builder.apply("RegexLiteral", arguments); } export { RegexLiteral as regexLiteral }; /** @deprecated */ -function RestProperty(...args: Array): any { +function RestProperty(argument: t.LVal): t.RestProperty { console.trace("The node type RestProperty has been renamed to RestElement"); return builder.apply("RestProperty", arguments); } export { RestProperty as restProperty }; /** @deprecated */ -function SpreadProperty(...args: Array): any { +function SpreadProperty(argument: t.Expression): t.SpreadProperty { console.trace( "The node type SpreadProperty has been renamed to SpreadElement", );