Socket
Socket
Sign inDemoInstall

@babel/generator

Package Overview
Dependencies
10
Maintainers
4
Versions
170
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 7.19.6 to 7.20.0

21

lib/generators/expressions.js

@@ -58,3 +58,6 @@ "use strict";

this.word("async");
this.space();
this.ensureNoLineTerminator(() => {
this.printInnerComments(node);
this.space();
});
}

@@ -238,8 +241,16 @@

if (node.delegate) {
this.ensureNoLineTerminator(() => {
this.printInnerComments(node);
});
this.tokenChar(42);
}
if (node.argument) {
this.space();
this.printTerminatorless(node.argument, node, false);
if (node.argument) {
this.space();
this.print(node.argument, node);
}
} else {
if (node.argument) {
this.space();
this.printTerminatorless(node.argument, node, false);
}
}

@@ -246,0 +257,0 @@ }

@@ -32,3 +32,5 @@ "use strict";

function _parameters(parameters, parent) {
for (let i = 0; i < parameters.length; i++) {
const paramLength = parameters.length;
for (let i = 0; i < paramLength; i++) {
this._param(parameters[i], parent);

@@ -41,2 +43,6 @@

}
if (paramLength === 0) {
this.printInnerComments(parent);
}
}

@@ -64,5 +70,8 @@

const {
_noLineTerminator
} = this;
if (node.async) {
this._catchUp("start", key.loc);
this._noLineTerminator = true;
this.word("async");

@@ -74,3 +83,8 @@ this.space();

if (node.generator) {
if (node.async) {
this.printInnerComments(node);
}
this.tokenChar(42);
this._noLineTerminator = _noLineTerminator;
}

@@ -81,6 +95,9 @@ }

this.tokenChar(91);
this._noLineTerminator = _noLineTerminator;
this.print(key, node);
this.tokenChar(93);
this.printInnerComments(node);
} else {
this.print(key, node);
this._noLineTerminator = _noLineTerminator;
}

@@ -136,3 +153,8 @@

function ArrowFunctionExpression(node) {
const {
_noLineTerminator
} = this;
if (node.async) {
this._noLineTerminator = true;
this.word("async");

@@ -142,7 +164,10 @@ this.space();

const firstParam = node.params[0];
let firstParam;
if (!this.format.retainLines && !this.format.auxiliaryCommentBefore && !this.format.auxiliaryCommentAfter && node.params.length === 1 && isIdentifier(firstParam) && !hasTypesOrComments(node, firstParam)) {
if (!this.format.retainLines && node.params.length === 1 && isIdentifier(firstParam = node.params[0]) && !hasTypesOrComments(node, firstParam)) {
this.print(firstParam, node);
this._noLineTerminator = _noLineTerminator;
} else {
this._noLineTerminator = _noLineTerminator;
this._params(node);

@@ -153,5 +178,8 @@ }

this.ensureNoLineTerminator(() => {
this.space();
this.printInnerComments(node);
this.token("=>");
});
this.space();
this.token("=>");
this.space();
this.print(node.body, node);

@@ -158,0 +186,0 @@ }

@@ -78,2 +78,4 @@ "use strict";

function ExportAllDeclaration(node) {
var _node$assertions;
this.word("export");

@@ -91,4 +93,14 @@ this.space();

this.space();
this.print(node.source, node);
this.printAssertions(node);
if ((_node$assertions = node.assertions) != null && _node$assertions.length) {
this.ensureNoLineTerminator(() => {
this.print(node.source, node);
this.space();
this.word("assert");
});
this.printAssertions(node);
} else {
this.print(node.source, node);
}
this.semicolon();

@@ -148,7 +160,18 @@ }

if (node.source) {
var _node$assertions2;
this.space();
this.word("from");
this.space();
this.print(node.source, node);
this.printAssertions(node);
if ((_node$assertions2 = node.assertions) != null && _node$assertions2.length) {
this.ensureNoLineTerminator(() => {
this.print(node.source, node);
this.space();
this.word("assert");
});
this.printAssertions(node);
} else {
this.print(node.source, node);
}
}

@@ -167,2 +190,3 @@

this.word("export");
this.printInnerComments(node);
this.space();

@@ -177,2 +201,4 @@ this.word("default");

function ImportDeclaration(node) {
var _node$assertions3;
this.word("import");

@@ -183,4 +209,9 @@ this.space();

if (isTypeKind) {
this.printInnerComments(node, false);
this.word(node.importKind);
this.space();
} else if (node.module) {
this.printInnerComments(node, false);
this.word("module");
this.space();
}

@@ -223,4 +254,13 @@

this.print(node.source, node);
this.printAssertions(node);
if ((_node$assertions3 = node.assertions) != null && _node$assertions3.length) {
this.print(node.source, node, true);
this.ensureNoLineTerminator(() => {
this.space();
this.word("assert");
});
this.printAssertions(node);
} else {
this.print(node.source, node);
}
{

@@ -227,0 +267,0 @@ var _node$attributes;

@@ -130,2 +130,3 @@ "use strict";

this.printInnerComments(node, false);
this.tokenChar(40);

@@ -279,3 +280,14 @@ this.print(node.left, node);

this.word(node.kind);
const {
kind
} = node;
this.word(kind);
const {
_noLineTerminator
} = this;
if (kind === "using") {
this._noLineTerminator = true;
}
this.space();

@@ -292,2 +304,12 @@ let hasInits = false;

let iterator;
if (kind === "using") {
iterator = (_, i) => {
if (i === 0) {
this._noLineTerminator = _noLineTerminator;
}
};
}
this.printList(node.declarations, node, {

@@ -298,2 +320,3 @@ separator: hasInits ? function () {

} : undefined,
iterator,
indent: node.declarations.length > 1 ? true : false

@@ -300,0 +323,0 @@ });

@@ -8,3 +8,3 @@ "use strict";

exports.TSArrayType = TSArrayType;
exports.TSAsExpression = TSAsExpression;
exports.TSSatisfiesExpression = exports.TSAsExpression = TSTypeExpression;
exports.TSBigIntKeyword = TSBigIntKeyword;

@@ -604,10 +604,14 @@ exports.TSBooleanKeyword = TSBooleanKeyword;

function TSAsExpression(node) {
function TSTypeExpression(node) {
var _expression$trailingC;
const {
type,
expression,
typeAnnotation
} = node;
this.print(expression, node);
const forceParens = !!((_expression$trailingC = expression.trailingComments) != null && _expression$trailingC.length);
this.print(expression, node, true, undefined, forceParens);
this.space();
this.word("as");
this.word(type === "TSAsExpression" ? "as" : "satisfies");
this.space();

@@ -614,0 +618,0 @@ this.print(typeAnnotation, node);

@@ -22,6 +22,5 @@ "use strict";

exports.SequenceExpression = SequenceExpression;
exports.TSAsExpression = TSAsExpression;
exports.TSTypeAssertion = exports.TSSatisfiesExpression = exports.TSAsExpression = TSAsExpression;
exports.TSInferType = TSInferType;
exports.TSInstantiationExpression = TSInstantiationExpression;
exports.TSTypeAssertion = TSTypeAssertion;
exports.TSIntersectionType = exports.TSUnionType = TSUnionType;

@@ -85,3 +84,4 @@ exports.UnaryLike = UnaryLike;

isWhileStatement,
isYieldExpression
isYieldExpression,
isTSSatisfiesExpression
} = _t;

@@ -185,6 +185,2 @@ const PRECEDENCE = {

function TSTypeAssertion() {
return true;
}
function TSUnionType(node, parent) {

@@ -240,3 +236,3 @@ return isTSArrayType(parent) || isTSOptionalType(parent) || isTSIntersectionType(parent) || isTSUnionType(parent) || isTSRestType(parent);

test: node
}) || isAwaitExpression(parent) || isTSTypeAssertion(parent) || isTSAsExpression(parent)) {
}) || isAwaitExpression(parent) || isTSTypeAssertion(parent) || isTSAsExpression(parent) || isTSSatisfiesExpression(parent)) {
return true;

@@ -243,0 +239,0 @@ }

@@ -377,3 +377,3 @@ "use strict";

print(node, parent, noLineTerminator, trailingCommentsLineOffset) {
print(node, parent, noLineTerminator, trailingCommentsLineOffset, forceParens) {
if (!node) return;

@@ -403,4 +403,6 @@ const nodeType = node.type;

if (format.retainFunctionParens && nodeType === "FunctionExpression" && node.extra && node.extra.parenthesized) {
if (forceParens) {
shouldPrintParens = true;
} else if (format.retainFunctionParens && nodeType === "FunctionExpression" && node.extra && node.extra.parenthesized) {
shouldPrintParens = true;
} else {

@@ -749,14 +751,9 @@ shouldPrintParens = needsParens(node, parent, this._printStack);

printAssertions(node) {
var _node$assertions;
if ((_node$assertions = node.assertions) != null && _node$assertions.length) {
this.space();
this.word("assert");
this.space();
this.tokenChar(123);
this.space();
this.printList(node.assertions, node);
this.space();
this.tokenChar(125);
}
this.space();
this.printInnerComments(node);
this.tokenChar(123);
this.space();
this.printList(node.assertions, node);
this.space();
this.tokenChar(125);
}

@@ -763,0 +760,0 @@

{
"name": "@babel/generator",
"version": "7.19.6",
"version": "7.20.0",
"description": "Turns an AST into code.",

@@ -22,3 +22,3 @@ "author": "The Babel Team (https://babel.dev/team)",

"dependencies": {
"@babel/types": "^7.19.4",
"@babel/types": "^7.20.0",
"@jridgewell/gen-mapping": "^0.3.2",

@@ -29,3 +29,3 @@ "jsesc": "^2.5.1"

"@babel/helper-fixtures": "^7.19.4",
"@babel/parser": "^7.19.6",
"@babel/parser": "^7.20.0",
"@jridgewell/trace-mapping": "^0.3.8",

@@ -32,0 +32,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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc