@babel/generator
Advanced tools
Comparing version 7.21.4 to 7.21.5
@@ -54,4 +54,3 @@ "use strict"; | ||
}); | ||
this.sourceWithOffset("end", node.loc, 0, -1); | ||
this.rightBrace(); | ||
this.rightBrace(node); | ||
} | ||
@@ -58,0 +57,0 @@ function Directive(node) { |
@@ -65,4 +65,3 @@ "use strict"; | ||
if (!this.endsWith(10)) this.newline(); | ||
this.sourceWithOffset("end", node.loc, 0, -1); | ||
this.rightBrace(); | ||
this.rightBrace(node); | ||
} | ||
@@ -175,4 +174,3 @@ } | ||
}); | ||
this.sourceWithOffset("end", node.loc, 0, -1); | ||
this.rightBrace(); | ||
this.rightBrace(node); | ||
} | ||
@@ -179,0 +177,0 @@ } |
@@ -42,7 +42,10 @@ "use strict"; | ||
function UnaryExpression(node) { | ||
if (node.operator === "void" || node.operator === "delete" || node.operator === "typeof" || node.operator === "throw") { | ||
this.word(node.operator); | ||
const { | ||
operator | ||
} = node; | ||
if (operator === "void" || operator === "delete" || operator === "typeof" || operator === "throw") { | ||
this.word(operator); | ||
this.space(); | ||
} else { | ||
this.token(node.operator); | ||
this.token(operator); | ||
} | ||
@@ -63,3 +66,3 @@ this.print(node.argument, node); | ||
this.print(node.expression, node); | ||
this.tokenChar(41); | ||
this.rightParens(node); | ||
} | ||
@@ -102,3 +105,3 @@ function UpdateExpression(node) { | ||
this.printList(node.arguments, node); | ||
this.tokenChar(41); | ||
this.rightParens(node); | ||
} | ||
@@ -151,11 +154,17 @@ function SequenceExpression(node) { | ||
function OptionalMemberExpression(node) { | ||
let { | ||
computed | ||
} = node; | ||
const { | ||
optional, | ||
property | ||
} = node; | ||
this.print(node.object, node); | ||
if (!node.computed && isMemberExpression(node.property)) { | ||
if (!computed && isMemberExpression(property)) { | ||
throw new TypeError("Got a MemberExpression for MemberExpression property"); | ||
} | ||
let computed = node.computed; | ||
if (isLiteral(node.property) && typeof node.property.value === "number") { | ||
if (isLiteral(property) && typeof property.value === "number") { | ||
computed = true; | ||
} | ||
if (node.optional) { | ||
if (optional) { | ||
this.token("?."); | ||
@@ -165,9 +174,9 @@ } | ||
this.tokenChar(91); | ||
this.print(node.property, node); | ||
this.print(property, node); | ||
this.tokenChar(93); | ||
} else { | ||
if (!node.optional) { | ||
if (!optional) { | ||
this.tokenChar(46); | ||
} | ||
this.print(node.property, node); | ||
this.print(property, node); | ||
} | ||
@@ -184,3 +193,3 @@ } | ||
this.printList(node.arguments, node); | ||
this.tokenChar(41); | ||
this.rightParens(node); | ||
} | ||
@@ -193,3 +202,3 @@ function CallExpression(node) { | ||
this.printList(node.arguments, node); | ||
this.tokenChar(41); | ||
this.rightParens(node); | ||
} | ||
@@ -304,6 +313,5 @@ function Import() { | ||
this.dedent(); | ||
this.sourceWithOffset("end", node.loc, 0, -1); | ||
this.rightBrace(); | ||
this.rightBrace(node); | ||
} | ||
//# sourceMappingURL=expressions.js.map |
@@ -338,3 +338,4 @@ "use strict"; | ||
this.tokenChar(41); | ||
if (parent && (parent.type === "ObjectTypeCallProperty" || parent.type === "ObjectTypeInternalSlot" || parent.type === "DeclareFunction" || parent.type === "ObjectTypeProperty" && parent.method)) { | ||
const type = parent == null ? void 0 : parent.type; | ||
if (type != null && (type === "ObjectTypeCallProperty" || type === "ObjectTypeInternalSlot" || type === "DeclareFunction" || type === "ObjectTypeProperty" && parent.method)) { | ||
this.tokenChar(58); | ||
@@ -371,14 +372,17 @@ } else { | ||
} | ||
if (node.mixins && node.mixins.length) { | ||
this.space(); | ||
this.word("mixins"); | ||
this.space(); | ||
this.printList(node.mixins, node); | ||
if (node.type === "DeclareClass") { | ||
var _node$mixins, _node$implements; | ||
if ((_node$mixins = node.mixins) != null && _node$mixins.length) { | ||
this.space(); | ||
this.word("mixins"); | ||
this.space(); | ||
this.printList(node.mixins, node); | ||
} | ||
if ((_node$implements = node.implements) != null && _node$implements.length) { | ||
this.space(); | ||
this.word("implements"); | ||
this.space(); | ||
this.printList(node.implements, node); | ||
} | ||
} | ||
if (node.implements && node.implements.length) { | ||
this.space(); | ||
this.word("implements"); | ||
this.space(); | ||
this.printList(node.implements, node); | ||
} | ||
this.space(); | ||
@@ -388,6 +392,8 @@ this.print(node.body, node); | ||
function _variance(node) { | ||
if (node.variance) { | ||
if (node.variance.kind === "plus") { | ||
var _node$variance; | ||
const kind = (_node$variance = node.variance) == null ? void 0 : _node$variance.kind; | ||
if (kind != null) { | ||
if (kind === "plus") { | ||
this.tokenChar(43); | ||
} else if (node.variance.kind === "minus") { | ||
} else if (kind === "minus") { | ||
this.tokenChar(45); | ||
@@ -408,4 +414,5 @@ } | ||
function InterfaceTypeAnnotation(node) { | ||
var _node$extends2; | ||
this.word("interface"); | ||
if (node.extends && node.extends.length) { | ||
if ((_node$extends2 = node.extends) != null && _node$extends2.length) { | ||
this.space(); | ||
@@ -412,0 +419,0 @@ this.word("extends"); |
@@ -208,3 +208,3 @@ "use strict"; | ||
}); | ||
this.tokenChar(125); | ||
this.rightBrace(node); | ||
} | ||
@@ -211,0 +211,0 @@ function SwitchCase(node) { |
@@ -322,4 +322,3 @@ "use strict"; | ||
} | ||
printer.sourceWithOffset("end", node.loc, 0, -1); | ||
printer.rightBrace(); | ||
printer.rightBrace(node); | ||
} | ||
@@ -326,0 +325,0 @@ function TSArrayType(node) { |
@@ -73,8 +73,13 @@ "use strict"; | ||
} | ||
rightBrace() { | ||
rightBrace(node) { | ||
if (this.format.minified) { | ||
this._buf.removeLastSemicolon(); | ||
} | ||
this.sourceWithOffset("end", node.loc, 0, -1); | ||
this.tokenChar(125); | ||
} | ||
rightParens(node) { | ||
this.sourceWithOffset("end", node.loc, 0, -1); | ||
this.tokenChar(41); | ||
} | ||
space(force = false) { | ||
@@ -274,6 +279,7 @@ if (this.format.compact) return; | ||
_catchUp(prop, loc) { | ||
var _loc$prop; | ||
if (!this.format.retainLines) return; | ||
const pos = loc ? loc[prop] : null; | ||
if ((pos == null ? void 0 : pos.line) != null) { | ||
const count = pos.line - this._buf.getCurrentLine(); | ||
const line = loc == null ? void 0 : (_loc$prop = loc[prop]) == null ? void 0 : _loc$prop.line; | ||
if (line != null) { | ||
const count = line - this._buf.getCurrentLine(); | ||
for (let i = 0; i < count; i++) { | ||
@@ -305,2 +311,3 @@ this._newline(); | ||
print(node, parent, noLineTerminatorAfter, trailingCommentsLineOffset, forceParens) { | ||
var _node$extra; | ||
if (!node) return; | ||
@@ -322,10 +329,3 @@ this._endsWithInnerRaw = false; | ||
this._maybeAddAuxComment(this._insideAux && !oldInAux); | ||
let shouldPrintParens = false; | ||
if (forceParens) { | ||
shouldPrintParens = true; | ||
} else if (format.retainFunctionParens && nodeType === "FunctionExpression" && node.extra && node.extra.parenthesized) { | ||
shouldPrintParens = true; | ||
} else { | ||
shouldPrintParens = needsParens(node, parent, this._printStack); | ||
} | ||
const shouldPrintParens = forceParens || format.retainFunctionParens && nodeType === "FunctionExpression" && ((_node$extra = node.extra) == null ? void 0 : _node$extra.parenthesized) || needsParens(node, parent, this._printStack); | ||
if (shouldPrintParens) { | ||
@@ -478,4 +478,5 @@ this.tokenChar(40); | ||
_printNewline(newLine, opts) { | ||
if (this.format.retainLines || this.format.compact) return; | ||
if (this.format.concise) { | ||
const format = this.format; | ||
if (format.retainLines || format.compact) return; | ||
if (format.concise) { | ||
this.space(); | ||
@@ -482,0 +483,0 @@ return; |
{ | ||
"name": "@babel/generator", | ||
"version": "7.21.4", | ||
"version": "7.21.5", | ||
"description": "Turns an AST into code.", | ||
@@ -22,3 +22,3 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"dependencies": { | ||
"@babel/types": "^7.21.4", | ||
"@babel/types": "^7.21.5", | ||
"@jridgewell/gen-mapping": "^0.3.2", | ||
@@ -29,4 +29,4 @@ "@jridgewell/trace-mapping": "^0.3.17", | ||
"devDependencies": { | ||
"@babel/helper-fixtures": "^7.21.0", | ||
"@babel/parser": "^7.21.4", | ||
"@babel/helper-fixtures": "^7.21.5", | ||
"@babel/parser": "^7.21.5", | ||
"@types/jsesc": "^2.5.0", | ||
@@ -33,0 +33,0 @@ "charcodes": "^0.2.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
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
477820
4750
Updated@babel/types@^7.21.5