@babel/generator
Advanced tools
Comparing version 7.25.0 to 7.25.4
@@ -15,5 +15,5 @@ "use strict"; | ||
if (node.program) { | ||
this.print(node.program.interpreter, node); | ||
this.print(node.program.interpreter); | ||
} | ||
this.print(node.program, node); | ||
this.print(node.program); | ||
} | ||
@@ -60,3 +60,3 @@ function Program(node) { | ||
function Directive(node) { | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
this.semicolon(); | ||
@@ -63,0 +63,0 @@ } |
@@ -36,5 +36,5 @@ "use strict"; | ||
this.space(); | ||
this.print(node.id, node); | ||
this.print(node.id); | ||
} | ||
this.print(node.typeParameters, node); | ||
this.print(node.typeParameters); | ||
if (node.superClass) { | ||
@@ -44,4 +44,4 @@ this.space(); | ||
this.space(); | ||
this.print(node.superClass, node); | ||
this.print(node.superTypeParameters, node); | ||
this.print(node.superClass); | ||
this.print(node.superTypeParameters); | ||
} | ||
@@ -55,3 +55,3 @@ if (node.implements) { | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -81,7 +81,7 @@ function ClassBody(node) { | ||
this.tokenChar(91); | ||
this.print(node.key, node); | ||
this.print(node.key); | ||
this.tokenChar(93); | ||
} else { | ||
this._variance(node); | ||
this.print(node.key, node); | ||
this.print(node.key); | ||
} | ||
@@ -94,3 +94,3 @@ if (node.optional) { | ||
} | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
if (node.value) { | ||
@@ -100,3 +100,3 @@ this.space(); | ||
this.space(); | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
} | ||
@@ -115,7 +115,7 @@ this.semicolon(); | ||
this.tokenChar(91); | ||
this.print(node.key, node); | ||
this.print(node.key); | ||
this.tokenChar(93); | ||
} else { | ||
this._variance(node); | ||
this.print(node.key, node); | ||
this.print(node.key); | ||
} | ||
@@ -128,3 +128,3 @@ if (node.optional) { | ||
} | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
if (node.value) { | ||
@@ -134,3 +134,3 @@ this.space(); | ||
this.space(); | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
} | ||
@@ -145,4 +145,4 @@ this.semicolon(); | ||
} | ||
this.print(node.key, node); | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.key); | ||
this.print(node.typeAnnotation); | ||
if (node.value) { | ||
@@ -152,3 +152,3 @@ this.space(); | ||
this.space(); | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
} | ||
@@ -160,3 +160,3 @@ this.semicolon(); | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -166,3 +166,3 @@ function ClassPrivateMethod(node) { | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -169,0 +169,0 @@ function _classMethodHead(node) { |
@@ -51,3 +51,3 @@ "use strict"; | ||
} | ||
this.print(node.argument, node); | ||
this.print(node.argument); | ||
} | ||
@@ -61,7 +61,7 @@ function DoExpression(node) { | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
function ParenthesizedExpression(node) { | ||
this.tokenChar(40); | ||
this.print(node.expression, node); | ||
this.print(node.expression); | ||
this.rightParens(node); | ||
@@ -72,3 +72,3 @@ } | ||
this.token(node.operator); | ||
this.print(node.argument, node); | ||
this.print(node.argument); | ||
} else { | ||
@@ -80,11 +80,11 @@ this.printTerminatorless(node.argument, node, true); | ||
function ConditionalExpression(node) { | ||
this.print(node.test, node); | ||
this.print(node.test); | ||
this.space(); | ||
this.tokenChar(63); | ||
this.space(); | ||
this.print(node.consequent, node); | ||
this.print(node.consequent); | ||
this.space(); | ||
this.tokenChar(58); | ||
this.space(); | ||
this.print(node.alternate, node); | ||
this.print(node.alternate); | ||
} | ||
@@ -94,3 +94,3 @@ function NewExpression(node, parent) { | ||
this.space(); | ||
this.print(node.callee, node); | ||
this.print(node.callee); | ||
if (this.format.minified && node.arguments.length === 0 && !node.optional && !isCallExpression(parent, { | ||
@@ -101,4 +101,4 @@ callee: node | ||
} | ||
this.print(node.typeArguments, node); | ||
this.print(node.typeParameters, node); | ||
this.print(node.typeArguments); | ||
this.print(node.typeParameters); | ||
if (node.optional) { | ||
@@ -130,3 +130,3 @@ this.token("?."); | ||
this.tokenChar(64); | ||
this.print(node.expression, node); | ||
this.print(node.expression); | ||
this.newline(); | ||
@@ -142,3 +142,3 @@ } | ||
} = node; | ||
this.print(node.object, node); | ||
this.print(node.object); | ||
if (!computed && isMemberExpression(property)) { | ||
@@ -155,3 +155,3 @@ throw new TypeError("Got a MemberExpression for MemberExpression property"); | ||
this.tokenChar(91); | ||
this.print(property, node); | ||
this.print(property); | ||
this.tokenChar(93); | ||
@@ -162,12 +162,12 @@ } else { | ||
} | ||
this.print(property, node); | ||
this.print(property); | ||
} | ||
} | ||
function OptionalCallExpression(node) { | ||
this.print(node.callee, node); | ||
this.print(node.typeParameters, node); | ||
this.print(node.callee); | ||
this.print(node.typeParameters); | ||
if (node.optional) { | ||
this.token("?."); | ||
} | ||
this.print(node.typeArguments, node); | ||
this.print(node.typeArguments); | ||
this.tokenChar(40); | ||
@@ -180,5 +180,5 @@ const exit = this.enterForStatementInit(false); | ||
function CallExpression(node) { | ||
this.print(node.callee, node); | ||
this.print(node.typeArguments, node); | ||
this.print(node.typeParameters, node); | ||
this.print(node.callee); | ||
this.print(node.typeArguments); | ||
this.print(node.typeParameters); | ||
this.tokenChar(40); | ||
@@ -206,3 +206,3 @@ const exit = this.enterForStatementInit(false); | ||
this.space(); | ||
this.print(node.argument, node); | ||
this.print(node.argument); | ||
} | ||
@@ -221,10 +221,10 @@ } else { | ||
this.tokenContext |= _index.TokenContext.expressionStatement; | ||
this.print(node.expression, node); | ||
this.print(node.expression); | ||
this.semicolon(); | ||
} | ||
function AssignmentPattern(node) { | ||
this.print(node.left, node); | ||
this.print(node.left); | ||
if (node.left.type === "Identifier") { | ||
if (node.left.optional) this.tokenChar(63); | ||
this.print(node.left.typeAnnotation, node); | ||
this.print(node.left.typeAnnotation); | ||
} | ||
@@ -234,6 +234,6 @@ this.space(); | ||
this.space(); | ||
this.print(node.right, node); | ||
this.print(node.right); | ||
} | ||
function AssignmentExpression(node) { | ||
this.print(node.left, node); | ||
this.print(node.left); | ||
this.space(); | ||
@@ -244,13 +244,14 @@ if (node.operator === "in" || node.operator === "instanceof") { | ||
this.token(node.operator); | ||
this._endsWithDiv = node.operator === "/"; | ||
} | ||
this.space(); | ||
this.print(node.right, node); | ||
this.print(node.right); | ||
} | ||
function BindExpression(node) { | ||
this.print(node.object, node); | ||
this.print(node.object); | ||
this.token("::"); | ||
this.print(node.callee, node); | ||
this.print(node.callee); | ||
} | ||
function MemberExpression(node) { | ||
this.print(node.object, node); | ||
this.print(node.object); | ||
if (!node.computed && isMemberExpression(node.property)) { | ||
@@ -266,3 +267,3 @@ throw new TypeError("Got a MemberExpression for MemberExpression property"); | ||
this.tokenChar(91); | ||
this.print(node.property, node); | ||
this.print(node.property); | ||
this.tokenChar(93); | ||
@@ -272,13 +273,13 @@ exit(); | ||
this.tokenChar(46); | ||
this.print(node.property, node); | ||
this.print(node.property); | ||
} | ||
} | ||
function MetaProperty(node) { | ||
this.print(node.meta, node); | ||
this.print(node.meta); | ||
this.tokenChar(46); | ||
this.print(node.property, node); | ||
this.print(node.property); | ||
} | ||
function PrivateName(node) { | ||
this.tokenChar(35); | ||
this.print(node.id, node); | ||
this.print(node.id); | ||
} | ||
@@ -300,3 +301,3 @@ function V8IntrinsicIdentifier(node) { | ||
} | ||
this.print(body, node); | ||
this.print(body); | ||
this.dedent(); | ||
@@ -303,0 +304,0 @@ this.rightBrace(node); |
@@ -92,3 +92,3 @@ "use strict"; | ||
function ArrayTypeAnnotation(node) { | ||
this.print(node.elementType, node, true); | ||
this.print(node.elementType, true); | ||
this.tokenChar(91); | ||
@@ -122,7 +122,7 @@ this.tokenChar(93); | ||
this.space(); | ||
this.print(node.id, node); | ||
this.print(node.id.typeAnnotation.typeAnnotation, node); | ||
this.print(node.id); | ||
this.print(node.id.typeAnnotation.typeAnnotation); | ||
if (node.predicate) { | ||
this.space(); | ||
this.print(node.predicate, node); | ||
this.print(node.predicate); | ||
} | ||
@@ -139,3 +139,3 @@ this.semicolon(); | ||
this.tokenChar(40); | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
this.tokenChar(41); | ||
@@ -153,5 +153,5 @@ } | ||
this.space(); | ||
this.print(node.id, node); | ||
this.print(node.id); | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -164,3 +164,3 @@ function DeclareModuleExports(node) { | ||
this.word("exports"); | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
} | ||
@@ -186,4 +186,4 @@ function DeclareTypeAlias(node) { | ||
this.space(); | ||
this.print(node.id, node); | ||
this.print(node.id.typeAnnotation, node); | ||
this.print(node.id); | ||
this.print(node.id.typeAnnotation); | ||
this.semicolon(); | ||
@@ -214,4 +214,4 @@ } | ||
this.space(); | ||
this.print(id, node); | ||
this.print(body, node); | ||
this.print(id); | ||
this.print(body); | ||
} | ||
@@ -235,3 +235,3 @@ function enumExplicitType(context, name, hasExplicitType) { | ||
for (const member of members) { | ||
context.print(member, node); | ||
context.print(member); | ||
context.newline(); | ||
@@ -275,15 +275,11 @@ } | ||
} = node; | ||
this.print(id, node); | ||
this.print(id); | ||
this.tokenChar(44); | ||
} | ||
function enumInitializedMember(context, node) { | ||
const { | ||
id, | ||
init | ||
} = node; | ||
context.print(id, node); | ||
context.print(node.id); | ||
context.space(); | ||
context.token("="); | ||
context.space(); | ||
context.print(init, node); | ||
context.print(node.init); | ||
context.token(","); | ||
@@ -303,3 +299,3 @@ } | ||
const declar = node.declaration; | ||
this.print(declar, node); | ||
this.print(declar); | ||
if (!isStatement(declar)) this.semicolon(); | ||
@@ -318,3 +314,3 @@ } else { | ||
this.space(); | ||
this.print(node.source, node); | ||
this.print(node.source); | ||
} | ||
@@ -328,3 +324,3 @@ this.semicolon(); | ||
function FunctionTypeAnnotation(node, parent) { | ||
this.print(node.typeParameters, node); | ||
this.print(node.typeParameters); | ||
this.tokenChar(40); | ||
@@ -335,3 +331,3 @@ if (node.this) { | ||
this.space(); | ||
this.print(node.this.typeAnnotation, node); | ||
this.print(node.this.typeAnnotation); | ||
if (node.params.length || node.rest) { | ||
@@ -349,3 +345,3 @@ this.tokenChar(44); | ||
this.token("..."); | ||
this.print(node.rest, node); | ||
this.print(node.rest); | ||
} | ||
@@ -361,6 +357,6 @@ this.tokenChar(41); | ||
this.space(); | ||
this.print(node.returnType, node); | ||
this.print(node.returnType); | ||
} | ||
function FunctionTypeParam(node) { | ||
this.print(node.name, node); | ||
this.print(node.name); | ||
if (node.optional) this.tokenChar(63); | ||
@@ -371,12 +367,12 @@ if (node.name) { | ||
} | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
} | ||
function InterfaceExtends(node) { | ||
this.print(node.id, node); | ||
this.print(node.typeParameters, node, true); | ||
this.print(node.id); | ||
this.print(node.typeParameters, true); | ||
} | ||
function _interfaceish(node) { | ||
var _node$extends; | ||
this.print(node.id, node); | ||
this.print(node.typeParameters, node); | ||
this.print(node.id); | ||
this.print(node.typeParameters); | ||
if ((_node$extends = node.extends) != null && _node$extends.length) { | ||
@@ -404,3 +400,3 @@ this.space(); | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -438,3 +434,3 @@ function _variance(node) { | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -454,3 +450,3 @@ function IntersectionTypeAnnotation(node) { | ||
this.tokenChar(63); | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
} | ||
@@ -474,3 +470,3 @@ function NumberTypeAnnotation() { | ||
this.space(); | ||
this.print(node.argument, node); | ||
this.print(node.argument); | ||
} | ||
@@ -480,8 +476,8 @@ function TypeAlias(node) { | ||
this.space(); | ||
this.print(node.id, node); | ||
this.print(node.typeParameters, node); | ||
this.print(node.id); | ||
this.print(node.typeParameters); | ||
this.space(); | ||
this.tokenChar(61); | ||
this.space(); | ||
this.print(node.right, node); | ||
this.print(node.right); | ||
this.semicolon(); | ||
@@ -497,3 +493,3 @@ } | ||
} | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
} | ||
@@ -509,3 +505,3 @@ function TypeParameterInstantiation(node) { | ||
if (node.bound) { | ||
this.print(node.bound, node); | ||
this.print(node.bound); | ||
} | ||
@@ -516,3 +512,3 @@ if (node.default) { | ||
this.space(); | ||
this.print(node.default, node); | ||
this.print(node.default); | ||
} | ||
@@ -525,8 +521,8 @@ } | ||
this.space(); | ||
this.print(node.id, node); | ||
this.print(node.typeParameters, node); | ||
this.print(node.id); | ||
this.print(node.typeParameters); | ||
if (node.supertype) { | ||
this.tokenChar(58); | ||
this.space(); | ||
this.print(node.supertype, node); | ||
this.print(node.supertype); | ||
} | ||
@@ -537,3 +533,3 @@ if (node.impltype) { | ||
this.space(); | ||
this.print(node.impltype, node); | ||
this.print(node.impltype); | ||
} | ||
@@ -588,3 +584,3 @@ this.semicolon(); | ||
this.tokenChar(91); | ||
this.print(node.id, node); | ||
this.print(node.id); | ||
this.tokenChar(93); | ||
@@ -597,3 +593,3 @@ this.tokenChar(93); | ||
} | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
} | ||
@@ -605,3 +601,3 @@ function ObjectTypeCallProperty(node) { | ||
} | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
} | ||
@@ -616,11 +612,11 @@ function ObjectTypeIndexer(node) { | ||
if (node.id) { | ||
this.print(node.id, node); | ||
this.print(node.id); | ||
this.tokenChar(58); | ||
this.space(); | ||
} | ||
this.print(node.key, node); | ||
this.print(node.key); | ||
this.tokenChar(93); | ||
this.tokenChar(58); | ||
this.space(); | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
} | ||
@@ -641,3 +637,3 @@ function ObjectTypeProperty(node) { | ||
this._variance(node); | ||
this.print(node.key, node); | ||
this.print(node.key); | ||
if (node.optional) this.tokenChar(63); | ||
@@ -648,12 +644,12 @@ if (!node.method) { | ||
} | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
} | ||
function ObjectTypeSpreadProperty(node) { | ||
this.token("..."); | ||
this.print(node.argument, node); | ||
this.print(node.argument); | ||
} | ||
function QualifiedTypeIdentifier(node) { | ||
this.print(node.qualification, node); | ||
this.print(node.qualification); | ||
this.tokenChar(46); | ||
this.print(node.id, node); | ||
this.print(node.id); | ||
} | ||
@@ -675,4 +671,4 @@ function SymbolTypeAnnotation() { | ||
this.tokenChar(40); | ||
this.print(node.expression, node); | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.expression); | ||
this.print(node.typeAnnotation); | ||
this.tokenChar(41); | ||
@@ -691,9 +687,9 @@ } | ||
function IndexedAccessType(node) { | ||
this.print(node.objectType, node, true); | ||
this.print(node.objectType, true); | ||
this.tokenChar(91); | ||
this.print(node.indexType, node); | ||
this.print(node.indexType); | ||
this.tokenChar(93); | ||
} | ||
function OptionalIndexedAccessType(node) { | ||
this.print(node.objectType, node); | ||
this.print(node.objectType); | ||
if (node.optional) { | ||
@@ -703,3 +699,3 @@ this.token("?."); | ||
this.tokenChar(91); | ||
this.print(node.indexType, node); | ||
this.print(node.indexType); | ||
this.tokenChar(93); | ||
@@ -706,0 +702,0 @@ } |
@@ -22,6 +22,6 @@ "use strict"; | ||
function JSXAttribute(node) { | ||
this.print(node.name, node); | ||
this.print(node.name); | ||
if (node.value) { | ||
this.tokenChar(61); | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
} | ||
@@ -33,10 +33,10 @@ } | ||
function JSXNamespacedName(node) { | ||
this.print(node.namespace, node); | ||
this.print(node.namespace); | ||
this.tokenChar(58); | ||
this.print(node.name, node); | ||
this.print(node.name); | ||
} | ||
function JSXMemberExpression(node) { | ||
this.print(node.object, node); | ||
this.print(node.object); | ||
this.tokenChar(46); | ||
this.print(node.property, node); | ||
this.print(node.property); | ||
} | ||
@@ -46,3 +46,3 @@ function JSXSpreadAttribute(node) { | ||
this.token("..."); | ||
this.print(node.argument, node); | ||
this.print(node.argument); | ||
this.tokenChar(125); | ||
@@ -52,3 +52,3 @@ } | ||
this.tokenChar(123); | ||
this.print(node.expression, node); | ||
this.print(node.expression); | ||
this.tokenChar(125); | ||
@@ -59,3 +59,3 @@ } | ||
this.token("..."); | ||
this.print(node.expression, node); | ||
this.print(node.expression); | ||
this.tokenChar(125); | ||
@@ -73,10 +73,10 @@ } | ||
const open = node.openingElement; | ||
this.print(open, node); | ||
this.print(open); | ||
if (open.selfClosing) return; | ||
this.indent(); | ||
for (const child of node.children) { | ||
this.print(child, node); | ||
this.print(child); | ||
} | ||
this.dedent(); | ||
this.print(node.closingElement, node); | ||
this.print(node.closingElement); | ||
} | ||
@@ -88,4 +88,4 @@ function spaceSeparator() { | ||
this.tokenChar(60); | ||
this.print(node.name, node); | ||
this.print(node.typeParameters, node); | ||
this.print(node.name); | ||
this.print(node.typeParameters); | ||
if (node.attributes.length > 0) { | ||
@@ -106,3 +106,3 @@ this.space(); | ||
this.token("</"); | ||
this.print(node.name, node); | ||
this.print(node.name); | ||
this.tokenChar(62); | ||
@@ -114,9 +114,9 @@ } | ||
function JSXFragment(node) { | ||
this.print(node.openingFragment, node); | ||
this.print(node.openingFragment); | ||
this.indent(); | ||
for (const child of node.children) { | ||
this.print(child, node); | ||
this.print(child); | ||
} | ||
this.dedent(); | ||
this.print(node.closingFragment, node); | ||
this.print(node.closingFragment); | ||
} | ||
@@ -123,0 +123,0 @@ function JSXOpeningFragment() { |
@@ -20,3 +20,3 @@ "use strict"; | ||
function _params(node, idNode, parentNode) { | ||
this.print(node.typeParameters, node); | ||
this.print(node.typeParameters); | ||
const nameInfo = _getFuncIdName.call(this, idNode, parentNode); | ||
@@ -27,13 +27,13 @@ if (nameInfo) { | ||
this.tokenChar(40); | ||
this._parameters(node.params, node); | ||
this._parameters(node.params); | ||
this.tokenChar(41); | ||
const noLineTerminator = node.type === "ArrowFunctionExpression"; | ||
this.print(node.returnType, node, noLineTerminator); | ||
this.print(node.returnType, noLineTerminator); | ||
this._noLineTerminator = noLineTerminator; | ||
} | ||
function _parameters(parameters, parent) { | ||
function _parameters(parameters) { | ||
const exit = this.enterForStatementInit(false); | ||
const paramLength = parameters.length; | ||
for (let i = 0; i < paramLength; i++) { | ||
this._param(parameters[i], parent); | ||
this._param(parameters[i]); | ||
if (i < parameters.length - 1) { | ||
@@ -46,9 +46,9 @@ this.tokenChar(44); | ||
} | ||
function _param(parameter, parent) { | ||
function _param(parameter) { | ||
this.printJoin(parameter.decorators, parameter); | ||
this.print(parameter, parent); | ||
this.print(parameter); | ||
if (parameter.optional) { | ||
this.tokenChar(63); | ||
} | ||
this.print(parameter.typeAnnotation, parameter); | ||
this.print(parameter.typeAnnotation); | ||
} | ||
@@ -73,6 +73,6 @@ function _methodHead(node) { | ||
this.tokenChar(91); | ||
this.print(key, node); | ||
this.print(key); | ||
this.tokenChar(93); | ||
} else { | ||
this.print(key, node); | ||
this.print(key); | ||
} | ||
@@ -90,3 +90,3 @@ if (node.optional) { | ||
this.space(); | ||
this.print(node.predicate, node, noLineTerminatorAfter); | ||
this.print(node.predicate, noLineTerminatorAfter); | ||
} | ||
@@ -107,3 +107,3 @@ } | ||
if (node.id) { | ||
this.print(node.id, node); | ||
this.print(node.id); | ||
} | ||
@@ -118,3 +118,3 @@ this._params(node, node.id, parent); | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -128,3 +128,3 @@ function ArrowFunctionExpression(node, parent) { | ||
if (!this.format.retainLines && node.params.length === 1 && isIdentifier(firstParam = node.params[0]) && !hasTypesOrComments(node, firstParam)) { | ||
this.print(firstParam, node, true); | ||
this.print(firstParam, true); | ||
} else { | ||
@@ -139,3 +139,3 @@ this._params(node, undefined, parent); | ||
this.tokenContext |= _index.TokenContext.arrowBody; | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -142,0 +142,0 @@ function hasTypesOrComments(node, param) { |
@@ -34,3 +34,3 @@ "use strict"; | ||
} | ||
this.print(node.imported, node); | ||
this.print(node.imported); | ||
if (node.local && node.local.name !== node.imported.name) { | ||
@@ -40,10 +40,10 @@ this.space(); | ||
this.space(); | ||
this.print(node.local, node); | ||
this.print(node.local); | ||
} | ||
} | ||
function ImportDefaultSpecifier(node) { | ||
this.print(node.local, node); | ||
this.print(node.local); | ||
} | ||
function ExportDefaultSpecifier(node) { | ||
this.print(node.exported, node); | ||
this.print(node.exported); | ||
} | ||
@@ -55,3 +55,3 @@ function ExportSpecifier(node) { | ||
} | ||
this.print(node.local, node); | ||
this.print(node.local); | ||
if (node.exported && node.local.name !== node.exported.name) { | ||
@@ -61,3 +61,3 @@ this.space(); | ||
this.space(); | ||
this.print(node.exported, node); | ||
this.print(node.exported); | ||
} | ||
@@ -70,3 +70,3 @@ } | ||
this.space(); | ||
this.print(node.exported, node); | ||
this.print(node.exported); | ||
} | ||
@@ -118,7 +118,7 @@ let warningShown = false; | ||
if ((_node$attributes = node.attributes) != null && _node$attributes.length || (_node$assertions = node.assertions) != null && _node$assertions.length) { | ||
this.print(node.source, node, true); | ||
this.print(node.source, true); | ||
this.space(); | ||
this._printAttributes(node); | ||
} else { | ||
this.print(node.source, node); | ||
this.print(node.source); | ||
} | ||
@@ -138,3 +138,3 @@ this.semicolon(); | ||
const declar = node.declaration; | ||
this.print(declar, node); | ||
this.print(declar); | ||
if (!isStatement(declar)) this.semicolon(); | ||
@@ -152,3 +152,3 @@ } else { | ||
hasSpecial = true; | ||
this.print(specifiers.shift(), node); | ||
this.print(specifiers.shift()); | ||
if (specifiers.length) { | ||
@@ -177,7 +177,7 @@ this.tokenChar(44); | ||
if ((_node$attributes2 = node.attributes) != null && _node$attributes2.length || (_node$assertions2 = node.assertions) != null && _node$assertions2.length) { | ||
this.print(node.source, node, true); | ||
this.print(node.source, true); | ||
this.space(); | ||
this._printAttributes(node); | ||
} else { | ||
this.print(node.source, node); | ||
this.print(node.source); | ||
} | ||
@@ -197,3 +197,3 @@ } | ||
const declar = node.declaration; | ||
this.print(declar, node); | ||
this.print(declar); | ||
if (!isStatement(declar)) this.semicolon(); | ||
@@ -224,3 +224,3 @@ } | ||
if (isImportDefaultSpecifier(first) || isImportNamespaceSpecifier(first)) { | ||
this.print(specifiers.shift(), node); | ||
this.print(specifiers.shift()); | ||
if (specifiers.length) { | ||
@@ -250,7 +250,7 @@ this.tokenChar(44); | ||
if ((_node$attributes3 = node.attributes) != null && _node$attributes3.length || (_node$assertions3 = node.assertions) != null && _node$assertions3.length) { | ||
this.print(node.source, node, true); | ||
this.print(node.source, true); | ||
this.space(); | ||
this._printAttributes(node); | ||
} else { | ||
this.print(node.source, node); | ||
this.print(node.source); | ||
} | ||
@@ -270,3 +270,3 @@ this.semicolon(); | ||
this.space(); | ||
this.print(node.local, node); | ||
this.print(node.local); | ||
} | ||
@@ -280,7 +280,7 @@ function ImportExpression(node) { | ||
this.tokenChar(40); | ||
this.print(node.source, node); | ||
this.print(node.source); | ||
if (node.options != null) { | ||
this.tokenChar(44); | ||
this.space(); | ||
this.print(node.options, node); | ||
this.print(node.options); | ||
} | ||
@@ -287,0 +287,0 @@ this.tokenChar(41); |
@@ -36,3 +36,3 @@ "use strict"; | ||
this.tokenChar(40); | ||
this.print(node.object, node); | ||
this.print(node.object); | ||
this.tokenChar(41); | ||
@@ -45,3 +45,3 @@ this.printBlock(node); | ||
this.tokenChar(40); | ||
this.print(node.test, node); | ||
this.print(node.test); | ||
this.tokenChar(41); | ||
@@ -55,3 +55,3 @@ this.space(); | ||
} | ||
this.printAndIndentOnComments(node.consequent, node); | ||
this.printAndIndentOnComments(node.consequent); | ||
if (needsBlock) { | ||
@@ -66,3 +66,3 @@ this.dedent(); | ||
this.space(); | ||
this.printAndIndentOnComments(node.alternate, node); | ||
this.printAndIndentOnComments(node.alternate); | ||
} | ||
@@ -86,3 +86,3 @@ } | ||
this.tokenContext |= _index.TokenContext.forHead; | ||
this.print(node.init, node); | ||
this.print(node.init); | ||
exit(); | ||
@@ -93,3 +93,3 @@ } | ||
this.space(); | ||
this.print(node.test, node); | ||
this.print(node.test); | ||
} | ||
@@ -99,3 +99,3 @@ this.tokenChar(59); | ||
this.space(); | ||
this.print(node.update, node); | ||
this.print(node.update); | ||
} | ||
@@ -109,3 +109,3 @@ this.tokenChar(41); | ||
this.tokenChar(40); | ||
this.print(node.test, node); | ||
this.print(node.test); | ||
this.tokenChar(41); | ||
@@ -127,3 +127,3 @@ this.printBlock(node); | ||
this.tokenContext |= isForOf ? _index.TokenContext.forOfHead : _index.TokenContext.forInHead; | ||
this.print(node.left, node); | ||
this.print(node.left); | ||
exit == null || exit(); | ||
@@ -134,3 +134,3 @@ } | ||
this.space(); | ||
this.print(node.right, node); | ||
this.print(node.right); | ||
this.tokenChar(41); | ||
@@ -144,3 +144,3 @@ this.printBlock(node); | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
this.space(); | ||
@@ -150,3 +150,3 @@ this.word("while"); | ||
this.tokenChar(40); | ||
this.print(node.test, node); | ||
this.print(node.test); | ||
this.tokenChar(41); | ||
@@ -179,6 +179,6 @@ this.semicolon(); | ||
function LabeledStatement(node) { | ||
this.print(node.label, node); | ||
this.print(node.label); | ||
this.tokenChar(58); | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -188,8 +188,8 @@ function TryStatement(node) { | ||
this.space(); | ||
this.print(node.block, node); | ||
this.print(node.block); | ||
this.space(); | ||
if (node.handlers) { | ||
this.print(node.handlers[0], node); | ||
this.print(node.handlers[0]); | ||
} else { | ||
this.print(node.handler, node); | ||
this.print(node.handler); | ||
} | ||
@@ -200,3 +200,3 @@ if (node.finalizer) { | ||
this.space(); | ||
this.print(node.finalizer, node); | ||
this.print(node.finalizer); | ||
} | ||
@@ -209,8 +209,8 @@ } | ||
this.tokenChar(40); | ||
this.print(node.param, node); | ||
this.print(node.param.typeAnnotation, node); | ||
this.print(node.param); | ||
this.print(node.param.typeAnnotation); | ||
this.tokenChar(41); | ||
this.space(); | ||
} | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -221,3 +221,3 @@ function SwitchStatement(node) { | ||
this.tokenChar(40); | ||
this.print(node.discriminant, node); | ||
this.print(node.discriminant); | ||
this.tokenChar(41); | ||
@@ -238,3 +238,3 @@ this.space(); | ||
this.space(); | ||
this.print(node.test, node); | ||
this.print(node.test); | ||
this.tokenChar(58); | ||
@@ -297,5 +297,5 @@ } else { | ||
function VariableDeclarator(node) { | ||
this.print(node.id, node); | ||
this.print(node.id); | ||
if (node.definite) this.tokenChar(33); | ||
this.print(node.id.typeAnnotation, node); | ||
this.print(node.id.typeAnnotation); | ||
if (node.init) { | ||
@@ -305,3 +305,3 @@ this.space(); | ||
this.space(); | ||
this.print(node.init, node); | ||
this.print(node.init); | ||
} | ||
@@ -308,0 +308,0 @@ } |
@@ -10,5 +10,5 @@ "use strict"; | ||
function TaggedTemplateExpression(node) { | ||
this.print(node.tag, node); | ||
this.print(node.typeParameters, node); | ||
this.print(node.quasi, node); | ||
this.print(node.tag); | ||
this.print(node.typeParameters); | ||
this.print(node.quasi); | ||
} | ||
@@ -25,3 +25,3 @@ function TemplateElement() { | ||
this.token(partRaw + "${", true); | ||
this.print(node.expressions[i], node); | ||
this.print(node.expressions[i]); | ||
partRaw = "}"; | ||
@@ -28,0 +28,0 @@ } |
@@ -42,3 +42,3 @@ "use strict"; | ||
this.token("..."); | ||
this.print(node.argument, node); | ||
this.print(node.argument); | ||
} | ||
@@ -65,3 +65,3 @@ function ObjectExpression(node) { | ||
this.space(); | ||
this.print(node.body, node); | ||
this.print(node.body); | ||
} | ||
@@ -72,10 +72,10 @@ function ObjectProperty(node) { | ||
this.tokenChar(91); | ||
this.print(node.key, node); | ||
this.print(node.key); | ||
this.tokenChar(93); | ||
} else { | ||
if (isAssignmentPattern(node.value) && isIdentifier(node.key) && node.key.name === node.value.left.name) { | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
return; | ||
} | ||
this.print(node.key, node); | ||
this.print(node.key); | ||
if (node.shorthand && isIdentifier(node.key) && isIdentifier(node.value) && node.key.name === node.value.name) { | ||
@@ -87,3 +87,3 @@ return; | ||
this.space(); | ||
this.print(node.value, node); | ||
this.print(node.value); | ||
} | ||
@@ -99,3 +99,3 @@ function ArrayExpression(node) { | ||
if (i > 0) this.space(); | ||
this.print(elem, node); | ||
this.print(elem); | ||
if (i < len - 1) this.tokenChar(44); | ||
@@ -156,3 +156,3 @@ } else { | ||
if (i > 0) this.space(); | ||
this.print(elem, node); | ||
this.print(elem); | ||
if (i < len - 1) this.tokenChar(44); | ||
@@ -226,6 +226,6 @@ } | ||
function PipelineTopicExpression(node) { | ||
this.print(node.expression, node); | ||
this.print(node.expression); | ||
} | ||
function PipelineBareFunction(node) { | ||
this.print(node.callee, node); | ||
this.print(node.callee); | ||
} | ||
@@ -232,0 +232,0 @@ function PipelinePrimaryTopicReference() { |
@@ -78,3 +78,3 @@ "use strict"; | ||
if (node.optional) this.tokenChar(63); | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
} | ||
@@ -103,3 +103,3 @@ function TSTypeParameterInstantiation(node, parent) { | ||
this.space(); | ||
this.print(node.constraint, node); | ||
this.print(node.constraint); | ||
} | ||
@@ -110,3 +110,3 @@ if (node.default) { | ||
this.space(); | ||
this.print(node.default, node); | ||
this.print(node.default); | ||
} | ||
@@ -131,16 +131,16 @@ } | ||
this._functionHead(node, parent); | ||
this.tokenChar(59); | ||
this.semicolon(); | ||
} | ||
function TSDeclareMethod(node) { | ||
this._classMethodHead(node); | ||
this.tokenChar(59); | ||
this.semicolon(); | ||
} | ||
function TSQualifiedName(node) { | ||
this.print(node.left, node); | ||
this.print(node.left); | ||
this.tokenChar(46); | ||
this.print(node.right, node); | ||
this.print(node.right); | ||
} | ||
function TSCallSignatureDeclaration(node) { | ||
this.tsPrintSignatureDeclarationBase(node); | ||
this.tokenChar(59); | ||
this.semicolon(); | ||
} | ||
@@ -151,3 +151,3 @@ function TSConstructSignatureDeclaration(node) { | ||
this.tsPrintSignatureDeclarationBase(node); | ||
this.tokenChar(59); | ||
this.semicolon(); | ||
} | ||
@@ -163,4 +163,4 @@ function TSPropertySignature(node) { | ||
this.tsPrintPropertyOrMethodName(node); | ||
this.print(node.typeAnnotation, node); | ||
this.tokenChar(59); | ||
this.print(node.typeAnnotation); | ||
this.semicolon(); | ||
} | ||
@@ -171,3 +171,3 @@ function tsPrintPropertyOrMethodName(node) { | ||
} | ||
this.print(node.key, node); | ||
this.print(node.key); | ||
if (node.computed) { | ||
@@ -190,3 +190,3 @@ this.tokenChar(93); | ||
this.tsPrintSignatureDeclarationBase(node); | ||
this.tokenChar(59); | ||
this.semicolon(); | ||
} | ||
@@ -207,6 +207,6 @@ function TSIndexSignature(node) { | ||
this.tokenChar(91); | ||
this._parameters(node.parameters, node); | ||
this._parameters(node.parameters); | ||
this.tokenChar(93); | ||
this.print(node.typeAnnotation, node); | ||
this.tokenChar(59); | ||
this.print(node.typeAnnotation); | ||
this.semicolon(); | ||
} | ||
@@ -272,5 +272,5 @@ function TSAnyKeyword() { | ||
const parameters = node.parameters; | ||
this.print(typeParameters, node); | ||
this.print(typeParameters); | ||
this.tokenChar(40); | ||
this._parameters(parameters, node); | ||
this._parameters(parameters); | ||
this.tokenChar(41); | ||
@@ -281,7 +281,7 @@ this.space(); | ||
const returnType = node.typeAnnotation; | ||
this.print(returnType.typeAnnotation, node); | ||
this.print(returnType.typeAnnotation); | ||
} | ||
function TSTypeReference(node) { | ||
this.print(node.typeName, node, true); | ||
this.print(node.typeParameters, node, true); | ||
this.print(node.typeName, true); | ||
this.print(node.typeParameters, true); | ||
} | ||
@@ -306,3 +306,3 @@ function TSTypePredicate(node) { | ||
if (node.typeParameters) { | ||
this.print(node.typeParameters, node); | ||
this.print(node.typeParameters); | ||
} | ||
@@ -322,3 +322,3 @@ } | ||
for (const member of members) { | ||
printer.print(member, node); | ||
printer.print(member); | ||
printer.newline(); | ||
@@ -331,3 +331,3 @@ } | ||
function TSArrayType(node) { | ||
this.print(node.elementType, node, true); | ||
this.print(node.elementType, true); | ||
this.token("[]"); | ||
@@ -341,3 +341,3 @@ } | ||
function TSOptionalType(node) { | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
this.tokenChar(63); | ||
@@ -347,10 +347,10 @@ } | ||
this.token("..."); | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
} | ||
function TSNamedTupleMember(node) { | ||
this.print(node.label, node); | ||
this.print(node.label); | ||
if (node.optional) this.tokenChar(63); | ||
this.tokenChar(58); | ||
this.space(); | ||
this.print(node.elementType, node); | ||
this.print(node.elementType); | ||
} | ||
@@ -394,3 +394,3 @@ function TSUnionType(node) { | ||
this.tokenChar(40); | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
this.tokenChar(41); | ||
@@ -401,8 +401,8 @@ } | ||
this.space(); | ||
this.print(node.typeAnnotation, node); | ||
this.print(node.typeAnnotation); | ||
} | ||
function TSIndexedAccessType(node) { | ||
this.print(node.objectType, node, true); | ||
this.print(node.objectType, true); | ||
this.tokenChar(91); | ||
this.print(node.indexType, node); | ||
this.print(node.indexType); | ||
this.tokenChar(93); | ||
@@ -430,3 +430,3 @@ } | ||
this.space(); | ||
this.print(typeParameter.constraint, typeParameter); | ||
this.print(typeParameter.constraint); | ||
if (nameType) { | ||
@@ -436,3 +436,3 @@ this.space(); | ||
this.space(); | ||
this.print(nameType, node); | ||
this.print(nameType); | ||
} | ||
@@ -447,3 +447,3 @@ this.tokenChar(93); | ||
this.space(); | ||
this.print(typeAnnotation, node); | ||
this.print(typeAnnotation); | ||
} | ||
@@ -459,7 +459,7 @@ this.space(); | ||
function TSLiteralType(node) { | ||
this.print(node.literal, node); | ||
this.print(node.literal); | ||
} | ||
function TSExpressionWithTypeArguments(node) { | ||
this.print(node.expression, node); | ||
this.print(node.typeParameters, node); | ||
this.print(node.expression); | ||
this.print(node.typeParameters); | ||
} | ||
@@ -480,4 +480,4 @@ function TSInterfaceDeclaration(node) { | ||
this.space(); | ||
this.print(id, node); | ||
this.print(typeParameters, node); | ||
this.print(id); | ||
this.print(typeParameters); | ||
if (extendz != null && extendz.length) { | ||
@@ -490,3 +490,3 @@ this.space(); | ||
this.space(); | ||
this.print(body, node); | ||
this.print(body); | ||
} | ||
@@ -509,9 +509,9 @@ function TSInterfaceBody(node) { | ||
this.space(); | ||
this.print(id, node); | ||
this.print(typeParameters, node); | ||
this.print(id); | ||
this.print(typeParameters); | ||
this.space(); | ||
this.tokenChar(61); | ||
this.space(); | ||
this.print(typeAnnotation, node); | ||
this.tokenChar(59); | ||
this.print(typeAnnotation); | ||
this.semicolon(); | ||
} | ||
@@ -526,7 +526,7 @@ function TSTypeExpression(node) { | ||
const forceParens = !!((_expression$trailingC = expression.trailingComments) != null && _expression$trailingC.length); | ||
this.print(expression, node, true, undefined, forceParens); | ||
this.print(expression, true, undefined, forceParens); | ||
this.space(); | ||
this.word(type === "TSAsExpression" ? "as" : "satisfies"); | ||
this.space(); | ||
this.print(typeAnnotation, node); | ||
this.print(typeAnnotation); | ||
} | ||
@@ -539,10 +539,10 @@ function TSTypeAssertion(node) { | ||
this.tokenChar(60); | ||
this.print(typeAnnotation, node); | ||
this.print(typeAnnotation); | ||
this.tokenChar(62); | ||
this.space(); | ||
this.print(expression, node); | ||
this.print(expression); | ||
} | ||
function TSInstantiationExpression(node) { | ||
this.print(node.expression, node); | ||
this.print(node.typeParameters, node); | ||
this.print(node.expression); | ||
this.print(node.typeParameters); | ||
} | ||
@@ -566,3 +566,3 @@ function TSEnumDeclaration(node) { | ||
this.space(); | ||
this.print(id, node); | ||
this.print(id); | ||
this.space(); | ||
@@ -576,3 +576,3 @@ tsPrintBraced(this, members, node); | ||
} = node; | ||
this.print(id, node); | ||
this.print(id); | ||
if (initializer) { | ||
@@ -582,3 +582,3 @@ this.space(); | ||
this.space(); | ||
this.print(initializer, node); | ||
this.print(initializer); | ||
} | ||
@@ -600,5 +600,5 @@ this.tokenChar(44); | ||
} | ||
this.print(id, node); | ||
this.print(id); | ||
if (!node.body) { | ||
this.tokenChar(59); | ||
this.semicolon(); | ||
return; | ||
@@ -609,7 +609,7 @@ } | ||
this.tokenChar(46); | ||
this.print(body.id, body); | ||
this.print(body.id); | ||
body = body.body; | ||
} | ||
this.space(); | ||
this.print(body, node); | ||
this.print(body); | ||
} | ||
@@ -627,10 +627,10 @@ function TSModuleBlock(node) { | ||
this.tokenChar(40); | ||
this.print(argument, node); | ||
this.print(argument); | ||
this.tokenChar(41); | ||
if (qualifier) { | ||
this.tokenChar(46); | ||
this.print(qualifier, node); | ||
this.print(qualifier); | ||
} | ||
if (typeParameters) { | ||
this.print(typeParameters, node); | ||
this.print(typeParameters); | ||
} | ||
@@ -650,16 +650,16 @@ } | ||
this.space(); | ||
this.print(id, node); | ||
this.print(id); | ||
this.space(); | ||
this.tokenChar(61); | ||
this.space(); | ||
this.print(moduleReference, node); | ||
this.tokenChar(59); | ||
this.print(moduleReference); | ||
this.semicolon(); | ||
} | ||
function TSExternalModuleReference(node) { | ||
this.token("require("); | ||
this.print(node.expression, node); | ||
this.print(node.expression); | ||
this.tokenChar(41); | ||
} | ||
function TSNonNullExpression(node) { | ||
this.print(node.expression, node); | ||
this.print(node.expression); | ||
this.tokenChar(33); | ||
@@ -672,4 +672,4 @@ } | ||
this.space(); | ||
this.print(node.expression, node); | ||
this.tokenChar(59); | ||
this.print(node.expression); | ||
this.semicolon(); | ||
} | ||
@@ -683,3 +683,4 @@ function TSNamespaceExportDeclaration(node) { | ||
this.space(); | ||
this.print(node.id, node); | ||
this.print(node.id); | ||
this.semicolon(); | ||
} | ||
@@ -691,8 +692,8 @@ function tsPrintSignatureDeclarationBase(node) { | ||
const parameters = node.parameters; | ||
this.print(typeParameters, node); | ||
this.print(typeParameters); | ||
this.tokenChar(40); | ||
this._parameters(parameters, node); | ||
this._parameters(parameters); | ||
this.tokenChar(41); | ||
const returnType = node.typeAnnotation; | ||
this.print(returnType, node); | ||
this.print(returnType); | ||
} | ||
@@ -699,0 +700,0 @@ function tsPrintClassMemberModifiers(node) { |
@@ -6,3 +6,2 @@ "use strict"; | ||
}); | ||
exports.ArrowFunctionExpression = ArrowFunctionExpression; | ||
exports.AssignmentExpression = AssignmentExpression; | ||
@@ -12,3 +11,3 @@ exports.Binary = Binary; | ||
exports.ClassExpression = ClassExpression; | ||
exports.ConditionalExpression = ConditionalExpression; | ||
exports.ArrowFunctionExpression = exports.ConditionalExpression = ConditionalExpression; | ||
exports.DoExpression = DoExpression; | ||
@@ -38,3 +37,2 @@ exports.FunctionExpression = FunctionExpression; | ||
isCallExpression, | ||
isExportDeclaration, | ||
isForOfStatement, | ||
@@ -45,3 +43,4 @@ isIndexedAccessType, | ||
isOptionalMemberExpression, | ||
isYieldExpression | ||
isYieldExpression, | ||
isStatement | ||
} = _t; | ||
@@ -78,5 +77,8 @@ const PRECEDENCE = new Map([["||", 0], ["??", 0], ["|>", 0], ["&&", 1], ["|", 2], ["^", 3], ["&", 4], ["==", 5], ["===", 5], ["!=", 5], ["!==", 5], ["<", 6], [">", 6], ["<=", 6], [">=", 6], ["in", 6], ["instanceof", 6], [">>", 7], ["<<", 7], [">>>", 7], ["+", 8], ["-", 8], ["*", 9], ["/", 9], ["%", 9], ["**", 10]]); | ||
} | ||
function ObjectExpression(node, parent, tokenContext) { | ||
function needsParenBeforeExpressionBrace(tokenContext) { | ||
return Boolean(tokenContext & (_index.TokenContext.expressionStatement | _index.TokenContext.arrowBody)); | ||
} | ||
function ObjectExpression(node, parent, tokenContext) { | ||
return needsParenBeforeExpressionBrace(tokenContext); | ||
} | ||
function DoExpression(node, parent, tokenContext) { | ||
@@ -138,6 +140,9 @@ return !node.async && Boolean(tokenContext & _index.TokenContext.expressionStatement); | ||
const parentType = parent.type; | ||
if (parentType === "ForStatement" || parentType === "ThrowStatement" || parentType === "ReturnStatement" || parentType === "IfStatement" && parent.test === node || parentType === "WhileStatement" && parent.test === node || parentType === "ForInStatement" && parent.right === node || parentType === "SwitchStatement" && parent.discriminant === node || parentType === "ExpressionStatement" && parent.expression === node) { | ||
if (parentType === "SequenceExpression" || parentType === "ParenthesizedExpression" || parentType === "MemberExpression" && parent.property === node || parentType === "OptionalMemberExpression" && parent.property === node || parentType === "TemplateLiteral") { | ||
return false; | ||
} | ||
return true; | ||
if (parentType === "ClassDeclaration" || parentType === "ClassExpression") { | ||
return parent.superClass === node; | ||
} | ||
return !isStatement(parent); | ||
} | ||
@@ -157,5 +162,2 @@ function YieldExpression(node, parent) { | ||
} | ||
function ArrowFunctionExpression(node, parent) { | ||
return isExportDeclaration(parent) || ConditionalExpression(node, parent); | ||
} | ||
function ConditionalExpression(node, parent) { | ||
@@ -171,4 +173,4 @@ const parentType = parent.type; | ||
} | ||
function AssignmentExpression(node, parent) { | ||
if (isObjectPattern(node.left)) { | ||
function AssignmentExpression(node, parent, tokenContext) { | ||
if (needsParenBeforeExpressionBrace(tokenContext) && isObjectPattern(node.left)) { | ||
return true; | ||
@@ -175,0 +177,0 @@ } else { |
@@ -39,2 +39,3 @@ "use strict"; | ||
this._endsWithWord = false; | ||
this._endsWithDiv = false; | ||
this._lastCommentLine = 0; | ||
@@ -103,3 +104,3 @@ this._endsWithInnerRaw = false; | ||
this._maybePrintInnerComments(); | ||
if (this._endsWithWord || str.charCodeAt(0) === 47 && this.endsWith(47)) { | ||
if (this._endsWithWord || this._endsWithDiv && str.charCodeAt(0) === 47) { | ||
this._space(); | ||
@@ -210,2 +211,3 @@ } | ||
this._endsWithInteger = false; | ||
this._endsWithDiv = false; | ||
} | ||
@@ -218,2 +220,3 @@ _appendChar(char) { | ||
this._endsWithInteger = false; | ||
this._endsWithDiv = false; | ||
} | ||
@@ -302,3 +305,3 @@ _queue(char) { | ||
this._noLineTerminator = true; | ||
this.print(node, parent); | ||
this.print(node); | ||
} else { | ||
@@ -309,3 +312,3 @@ const terminatorState = { | ||
this._parenPushNewlineState = terminatorState; | ||
this.print(node, parent); | ||
this.print(node); | ||
if (terminatorState.printed) { | ||
@@ -318,3 +321,3 @@ this.dedent(); | ||
} | ||
print(node, parent, noLineTerminatorAfter, trailingCommentsLineOffset, forceParens) { | ||
print(node, noLineTerminatorAfter, trailingCommentsLineOffset, forceParens) { | ||
var _node$extra, _node$leadingComments; | ||
@@ -333,3 +336,3 @@ if (!node) return; | ||
} | ||
const oldNode = this._currentNode; | ||
const parent = this._currentNode; | ||
this._currentNode = node; | ||
@@ -378,3 +381,3 @@ const oldInAux = this._insideAux; | ||
} | ||
this._currentNode = oldNode; | ||
this._currentNode = parent; | ||
format.concise = oldConcise; | ||
@@ -439,3 +442,3 @@ this._insideAux = oldInAux; | ||
if (opts.statement) this._printNewline(i === 0, newlineOpts); | ||
this.print(node, parent, undefined, opts.trailingCommentsLineOffset || 0); | ||
this.print(node, undefined, opts.trailingCommentsLineOffset || 0); | ||
opts.iterator == null || opts.iterator(node, i); | ||
@@ -460,6 +463,6 @@ if (i < len - 1) separator == null || separator(); | ||
} | ||
printAndIndentOnComments(node, parent) { | ||
printAndIndentOnComments(node) { | ||
const indent = node.leadingComments && node.leadingComments.length > 0; | ||
if (indent) this.indent(); | ||
this.print(node, parent); | ||
this.print(node); | ||
if (indent) this.dedent(); | ||
@@ -472,3 +475,3 @@ } | ||
} | ||
this.print(node, parent); | ||
this.print(node); | ||
} | ||
@@ -605,3 +608,3 @@ _printTrailingComments(node, parent, lineOffset) { | ||
} | ||
if (this.endsWith(47)) this._space(); | ||
if (this._endsWithDiv) this._space(); | ||
this.source("start", comment.loc); | ||
@@ -608,0 +611,0 @@ this._append(val, isBlockComment); |
{ | ||
"name": "@babel/generator", | ||
"version": "7.25.0", | ||
"version": "7.25.4", | ||
"description": "Turns an AST into code.", | ||
@@ -22,3 +22,3 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"dependencies": { | ||
"@babel/types": "^7.25.0", | ||
"@babel/types": "^7.25.4", | ||
"@jridgewell/gen-mapping": "^0.3.5", | ||
@@ -30,3 +30,3 @@ "@jridgewell/trace-mapping": "^0.3.25", | ||
"@babel/helper-fixtures": "^7.24.8", | ||
"@babel/parser": "^7.25.0", | ||
"@babel/parser": "^7.25.4", | ||
"@jridgewell/sourcemap-codec": "^1.4.15", | ||
@@ -33,0 +33,0 @@ "@types/jsesc": "^2.5.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4790
487995
Updated@babel/types@^7.25.4