@babel/generator
Advanced tools
Comparing version 7.24.8 to 7.24.9
@@ -22,7 +22,7 @@ "use strict"; | ||
exports.SequenceExpression = SequenceExpression; | ||
exports.TSTypeAssertion = exports.TSSatisfiesExpression = exports.TSAsExpression = TSAsExpression; | ||
exports.TSSatisfiesExpression = exports.TSAsExpression = TSAsExpression; | ||
exports.TSInferType = TSInferType; | ||
exports.TSInstantiationExpression = TSInstantiationExpression; | ||
exports.UnaryLike = exports.TSTypeAssertion = UnaryLike; | ||
exports.TSIntersectionType = exports.TSUnionType = TSUnionType; | ||
exports.UnaryLike = UnaryLike; | ||
exports.IntersectionTypeAnnotation = exports.UnionTypeAnnotation = UnionTypeAnnotation; | ||
@@ -46,2 +46,10 @@ exports.UpdateExpression = UpdateExpression; | ||
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 getBinaryPrecedence(node, nodeType) { | ||
if (nodeType === "BinaryExpression" || nodeType === "LogicalExpression") { | ||
return PRECEDENCE.get(node.operator); | ||
} | ||
if (nodeType === "TSAsExpression" || nodeType === "TSSatisfiesExpression") { | ||
return PRECEDENCE.get("in"); | ||
} | ||
} | ||
function isTSTypeExpression(nodeType) { | ||
@@ -77,3 +85,3 @@ return nodeType === "TSAsExpression" || nodeType === "TSSatisfiesExpression" || nodeType === "TSTypeAssertion"; | ||
const parentType = parent.type; | ||
if (node.operator === "**" && parentType === "BinaryExpression" && parent.operator === "**") { | ||
if (node.type === "BinaryExpression" && node.operator === "**" && parentType === "BinaryExpression" && parent.operator === "**") { | ||
return parent.left === node; | ||
@@ -87,6 +95,6 @@ } | ||
} | ||
if (parentType === "BinaryExpression" || parentType === "LogicalExpression") { | ||
const parentPos = PRECEDENCE.get(parent.operator); | ||
const nodePos = PRECEDENCE.get(node.operator); | ||
if (parentPos === nodePos && parent.right === node && parentType !== "LogicalExpression" || parentPos > nodePos) { | ||
const parentPos = getBinaryPrecedence(parent, parentType); | ||
if (parentPos != null) { | ||
const nodePos = getBinaryPrecedence(node, node.type); | ||
if (parentPos === nodePos && parentType === "BinaryExpression" && parent.right === node || parentPos > nodePos) { | ||
return true; | ||
@@ -104,4 +112,7 @@ } | ||
} | ||
function TSAsExpression() { | ||
return true; | ||
function TSAsExpression(node, parent) { | ||
if (parent.type === "BinaryExpression" && (parent.operator === "|" || parent.operator === "&") && node === parent.left) { | ||
return true; | ||
} | ||
return Binary(node, parent); | ||
} | ||
@@ -108,0 +119,0 @@ function TSUnionType(node, parent) { |
{ | ||
"name": "@babel/generator", | ||
"version": "7.24.8", | ||
"version": "7.24.9", | ||
"description": "Turns an AST into code.", | ||
@@ -22,3 +22,3 @@ "author": "The Babel Team (https://babel.dev/team)", | ||
"dependencies": { | ||
"@babel/types": "^7.24.8", | ||
"@babel/types": "^7.24.9", | ||
"@jridgewell/gen-mapping": "^0.3.5", | ||
@@ -25,0 +25,0 @@ "@jridgewell/trace-mapping": "^0.3.25", |
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
496110
4781
Updated@babel/types@^7.24.9