feat: refactoring project
This commit is contained in:
16
node_modules/@babel/generator/lib/generators/base.js
generated
vendored
16
node_modules/@babel/generator/lib/generators/base.js
generated
vendored
@@ -12,9 +12,9 @@ exports.Placeholder = Placeholder;
|
||||
exports.Program = Program;
|
||||
function File(node) {
|
||||
if (node.program) {
|
||||
this.print(node.program.interpreter, node);
|
||||
this.print(node.program.interpreter);
|
||||
}
|
||||
this.print(node.program, node);
|
||||
this.print(node.program);
|
||||
}
|
||||
function Program(node) {
|
||||
var _node$directives;
|
||||
@@ -24,23 +24,24 @@ function Program(node) {
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai;
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, node, {
|
||||
this.printSequence(node.directives, {
|
||||
trailingCommentsLineOffset: newline
|
||||
});
|
||||
if (!((_node$directives$trai = node.directives[directivesLen - 1].trailingComments) != null && _node$directives$trai.length)) {
|
||||
this.newline(newline);
|
||||
}
|
||||
}
|
||||
this.printSequence(node.body, node);
|
||||
this.printSequence(node.body);
|
||||
}
|
||||
function BlockStatement(node) {
|
||||
var _node$directives2;
|
||||
this.tokenChar(123);
|
||||
const exit = this.enterDelimited();
|
||||
const directivesLen = (_node$directives2 = node.directives) == null ? void 0 : _node$directives2.length;
|
||||
if (directivesLen) {
|
||||
var _node$directives$trai2;
|
||||
const newline = node.body.length ? 2 : 1;
|
||||
this.printSequence(node.directives, node, {
|
||||
this.printSequence(node.directives, {
|
||||
indent: true,
|
||||
trailingCommentsLineOffset: newline
|
||||
});
|
||||
@@ -48,15 +49,14 @@ function BlockStatement(node) {
|
||||
this.newline(newline);
|
||||
}
|
||||
}
|
||||
const exit = this.enterForStatementInit(false);
|
||||
this.printSequence(node.body, node, {
|
||||
this.printSequence(node.body, {
|
||||
indent: true
|
||||
});
|
||||
exit();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function Directive(node) {
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
this.semicolon();
|
||||
}
|
||||
const unescapedSingleQuoteRE = /(?:^|[^\\])(?:\\\\)*'/;
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/base.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/base.js.map
generated
vendored
File diff suppressed because one or more lines are too long
105
node_modules/@babel/generator/lib/generators/classes.js
generated
vendored
105
node_modules/@babel/generator/lib/generators/classes.js
generated
vendored
@@ -20,7 +20,7 @@ const {
|
||||
function ClassDeclaration(node, parent) {
|
||||
const inExport = isExportDefaultDeclaration(parent) || isExportNamedDeclaration(parent);
|
||||
if (!inExport || !this._shouldPrintDecoratorsBeforeExport(parent)) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.printJoin(node.decorators);
|
||||
}
|
||||
if (node.declare) {
|
||||
this.word("declare");
|
||||
@@ -33,24 +33,24 @@ function ClassDeclaration(node, parent) {
|
||||
this.word("class");
|
||||
if (node.id) {
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
}
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.typeParameters);
|
||||
if (node.superClass) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.superClass, node);
|
||||
this.print(node.superTypeParameters, node);
|
||||
this.print(node.superClass);
|
||||
this.print(node.superTypeParameters);
|
||||
}
|
||||
if (node.implements) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements, node);
|
||||
this.printList(node.implements);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function ClassBody(node) {
|
||||
this.tokenChar(123);
|
||||
@@ -58,28 +58,63 @@ function ClassBody(node) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
this.newline();
|
||||
const exit = this.enterForStatementInit(false);
|
||||
this.printSequence(node.body, node, {
|
||||
indent: true
|
||||
const separator = classBodyEmptySemicolonsPrinter(this, node);
|
||||
separator == null || separator(-1);
|
||||
const exit = this.enterDelimited();
|
||||
this.printJoin(node.body, {
|
||||
statement: true,
|
||||
indent: true,
|
||||
separator,
|
||||
printTrailingSeparator: true
|
||||
});
|
||||
exit();
|
||||
if (!this.endsWith(10)) this.newline();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
}
|
||||
function classBodyEmptySemicolonsPrinter(printer, node) {
|
||||
if (!printer.tokenMap || node.start == null || node.end == null) {
|
||||
return null;
|
||||
}
|
||||
const indexes = printer.tokenMap.getIndexes(node);
|
||||
if (!indexes) return null;
|
||||
let k = 1;
|
||||
let occurrenceCount = 0;
|
||||
let nextLocIndex = 0;
|
||||
const advanceNextLocIndex = () => {
|
||||
while (nextLocIndex < node.body.length && node.body[nextLocIndex].start == null) {
|
||||
nextLocIndex++;
|
||||
}
|
||||
};
|
||||
advanceNextLocIndex();
|
||||
return i => {
|
||||
if (nextLocIndex <= i) {
|
||||
nextLocIndex = i + 1;
|
||||
advanceNextLocIndex();
|
||||
}
|
||||
const end = nextLocIndex === node.body.length ? node.end : node.body[nextLocIndex].start;
|
||||
let tok;
|
||||
while (k < indexes.length && printer.tokenMap.matchesOriginal(tok = printer._tokens[indexes[k]], ";") && tok.start < end) {
|
||||
printer.token(";", undefined, occurrenceCount++);
|
||||
k++;
|
||||
}
|
||||
};
|
||||
}
|
||||
function ClassProperty(node) {
|
||||
var _node$key$loc;
|
||||
this.printJoin(node.decorators, node);
|
||||
const endLine = (_node$key$loc = node.key.loc) == null || (_node$key$loc = _node$key$loc.end) == null ? void 0 : _node$key$loc.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
this.printJoin(node.decorators);
|
||||
if (!node.static && !this.format.preserveFormat) {
|
||||
var _node$key$loc;
|
||||
const endLine = (_node$key$loc = node.key.loc) == null || (_node$key$loc = _node$key$loc.end) == null ? void 0 : _node$key$loc.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
}
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
if (node.computed) {
|
||||
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);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
@@ -87,18 +122,18 @@ function ClassProperty(node) {
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassAccessorProperty(node) {
|
||||
var _node$key$loc2;
|
||||
this.printJoin(node.decorators, node);
|
||||
this.printJoin(node.decorators);
|
||||
const endLine = (_node$key$loc2 = node.key.loc) == null || (_node$key$loc2 = _node$key$loc2.end) == null ? void 0 : _node$key$loc2.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
@@ -106,11 +141,11 @@ function ClassAccessorProperty(node) {
|
||||
this.space();
|
||||
if (node.computed) {
|
||||
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);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
@@ -118,46 +153,48 @@ function ClassAccessorProperty(node) {
|
||||
if (node.definite) {
|
||||
this.tokenChar(33);
|
||||
}
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassPrivateProperty(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.printJoin(node.decorators);
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.key, node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.key);
|
||||
this.print(node.typeAnnotation);
|
||||
if (node.value) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function ClassMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function ClassPrivateMethod(node) {
|
||||
this._classMethodHead(node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function _classMethodHead(node) {
|
||||
var _node$key$loc3;
|
||||
this.printJoin(node.decorators, node);
|
||||
const endLine = (_node$key$loc3 = node.key.loc) == null || (_node$key$loc3 = _node$key$loc3.end) == null ? void 0 : _node$key$loc3.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
this.printJoin(node.decorators);
|
||||
if (!this.format.preserveFormat) {
|
||||
var _node$key$loc3;
|
||||
const endLine = (_node$key$loc3 = node.key.loc) == null || (_node$key$loc3 = _node$key$loc3.end) == null ? void 0 : _node$key$loc3.line;
|
||||
if (endLine) this.catchUp(endLine);
|
||||
}
|
||||
this.tsPrintClassMemberModifiers(node);
|
||||
this._methodHead(node);
|
||||
}
|
||||
@@ -169,7 +206,7 @@ function StaticBlock(node) {
|
||||
this.tokenChar(125);
|
||||
} else {
|
||||
this.newline();
|
||||
this.printSequence(node.body, node, {
|
||||
this.printSequence(node.body, {
|
||||
indent: true
|
||||
});
|
||||
this.rightBrace(node);
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/classes.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/classes.js.map
generated
vendored
File diff suppressed because one or more lines are too long
109
node_modules/@babel/generator/lib/generators/expressions.js
generated
vendored
109
node_modules/@babel/generator/lib/generators/expressions.js
generated
vendored
@@ -36,7 +36,8 @@ const {
|
||||
isCallExpression,
|
||||
isLiteral,
|
||||
isMemberExpression,
|
||||
isNewExpression
|
||||
isNewExpression,
|
||||
isPattern
|
||||
} = _t;
|
||||
function UnaryExpression(node) {
|
||||
const {
|
||||
@@ -48,7 +49,7 @@ function UnaryExpression(node) {
|
||||
} else {
|
||||
this.token(operator);
|
||||
}
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
}
|
||||
function DoExpression(node) {
|
||||
if (node.async) {
|
||||
@@ -57,55 +58,62 @@ function DoExpression(node) {
|
||||
}
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function ParenthesizedExpression(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.expression, node);
|
||||
const exit = this.enterDelimited();
|
||||
this.print(node.expression);
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
function UpdateExpression(node) {
|
||||
if (node.prefix) {
|
||||
this.token(node.operator);
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
} else {
|
||||
this.printTerminatorless(node.argument, node, true);
|
||||
this.print(node.argument, true);
|
||||
this.token(node.operator);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
function NewExpression(node, parent) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.print(node.callee, node);
|
||||
this.print(node.callee);
|
||||
if (this.format.minified && node.arguments.length === 0 && !node.optional && !isCallExpression(parent, {
|
||||
callee: node
|
||||
}) && !isMemberExpression(parent) && !isNewExpression(parent)) {
|
||||
return;
|
||||
}
|
||||
this.print(node.typeArguments, node);
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.typeArguments);
|
||||
this.print(node.typeParameters);
|
||||
if (node.optional) {
|
||||
this.token("?.");
|
||||
}
|
||||
if (node.arguments.length === 0 && this.tokenMap && !this.tokenMap.endMatches(node, ")")) {
|
||||
return;
|
||||
}
|
||||
this.tokenChar(40);
|
||||
const exit = this.enterForStatementInit(false);
|
||||
this.printList(node.arguments, node);
|
||||
const exit = this.enterDelimited();
|
||||
this.printList(node.arguments, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma(")")
|
||||
});
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
function SequenceExpression(node) {
|
||||
this.printList(node.expressions, node);
|
||||
this.printList(node.expressions);
|
||||
}
|
||||
function ThisExpression() {
|
||||
this.word("this");
|
||||
@@ -121,7 +129,7 @@ function _shouldPrintDecoratorsBeforeExport(node) {
|
||||
}
|
||||
function Decorator(node) {
|
||||
this.tokenChar(64);
|
||||
this.print(node.expression, node);
|
||||
this.print(node.expression);
|
||||
this.newline();
|
||||
}
|
||||
function OptionalMemberExpression(node) {
|
||||
@@ -132,7 +140,7 @@ function OptionalMemberExpression(node) {
|
||||
optional,
|
||||
property
|
||||
} = node;
|
||||
this.print(node.object, node);
|
||||
this.print(node.object);
|
||||
if (!computed && isMemberExpression(property)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
@@ -144,35 +152,37 @@ function OptionalMemberExpression(node) {
|
||||
}
|
||||
if (computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(property, node);
|
||||
this.print(property);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
if (!optional) {
|
||||
this.tokenChar(46);
|
||||
}
|
||||
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);
|
||||
const exit = this.enterForStatementInit(false);
|
||||
this.printList(node.arguments, node);
|
||||
const exit = this.enterDelimited();
|
||||
this.printList(node.arguments);
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
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);
|
||||
const exit = this.enterForStatementInit(false);
|
||||
this.printList(node.arguments, node);
|
||||
const exit = this.enterDelimited();
|
||||
this.printList(node.arguments, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma(")")
|
||||
});
|
||||
exit();
|
||||
this.rightParens(node);
|
||||
}
|
||||
@@ -183,7 +193,7 @@ function AwaitExpression(node) {
|
||||
this.word("await");
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument, node, false);
|
||||
this.printTerminatorless(node.argument);
|
||||
}
|
||||
}
|
||||
function YieldExpression(node) {
|
||||
@@ -192,12 +202,12 @@ function YieldExpression(node) {
|
||||
this.tokenChar(42);
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
}
|
||||
} else {
|
||||
if (node.argument) {
|
||||
this.space();
|
||||
this.printTerminatorless(node.argument, node, false);
|
||||
this.printTerminatorless(node.argument);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -206,38 +216,39 @@ function EmptyStatement() {
|
||||
}
|
||||
function ExpressionStatement(node) {
|
||||
this.tokenContext |= _index.TokenContext.expressionStatement;
|
||||
this.print(node.expression, node);
|
||||
this.print(node.expression);
|
||||
this.semicolon();
|
||||
}
|
||||
function AssignmentPattern(node) {
|
||||
this.print(node.left, node);
|
||||
if (node.left.type === "Identifier") {
|
||||
this.print(node.left);
|
||||
if (node.left.type === "Identifier" || isPattern(node.left)) {
|
||||
if (node.left.optional) this.tokenChar(63);
|
||||
this.print(node.left.typeAnnotation, node);
|
||||
this.print(node.left.typeAnnotation);
|
||||
}
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
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();
|
||||
if (node.operator === "in" || node.operator === "instanceof") {
|
||||
this.word(node.operator);
|
||||
} else {
|
||||
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)) {
|
||||
throw new TypeError("Got a MemberExpression for MemberExpression property");
|
||||
}
|
||||
@@ -246,24 +257,24 @@ function MemberExpression(node) {
|
||||
computed = true;
|
||||
}
|
||||
if (computed) {
|
||||
const exit = this.enterForStatementInit(false);
|
||||
const exit = this.enterDelimited();
|
||||
this.tokenChar(91);
|
||||
this.print(node.property, node);
|
||||
this.print(node.property);
|
||||
this.tokenChar(93);
|
||||
exit();
|
||||
} else {
|
||||
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);
|
||||
}
|
||||
function V8IntrinsicIdentifier(node) {
|
||||
this.tokenChar(37);
|
||||
@@ -280,7 +291,7 @@ function ModuleExpression(node) {
|
||||
if (body.body.length || body.directives.length) {
|
||||
this.newline();
|
||||
}
|
||||
this.print(body, node);
|
||||
this.print(body);
|
||||
this.dedent();
|
||||
this.rightBrace(node);
|
||||
}
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/expressions.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/expressions.js.map
generated
vendored
File diff suppressed because one or more lines are too long
152
node_modules/@babel/generator/lib/generators/flow.js
generated
vendored
152
node_modules/@babel/generator/lib/generators/flow.js
generated
vendored
@@ -89,7 +89,7 @@ function AnyTypeAnnotation() {
|
||||
this.word("any");
|
||||
}
|
||||
function ArrayTypeAnnotation(node) {
|
||||
this.print(node.elementType, node, true);
|
||||
this.print(node.elementType, true);
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
@@ -118,11 +118,11 @@ function DeclareFunction(node, parent) {
|
||||
}
|
||||
this.word("function");
|
||||
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);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
@@ -134,7 +134,7 @@ function DeclaredPredicate(node) {
|
||||
this.tokenChar(37);
|
||||
this.word("checks");
|
||||
this.tokenChar(40);
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function DeclareInterface(node) {
|
||||
@@ -147,9 +147,9 @@ function DeclareModule(node) {
|
||||
this.space();
|
||||
this.word("module");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function DeclareModuleExports(node) {
|
||||
this.word("declare");
|
||||
@@ -157,7 +157,7 @@ function DeclareModuleExports(node) {
|
||||
this.word("module");
|
||||
this.tokenChar(46);
|
||||
this.word("exports");
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function DeclareTypeAlias(node) {
|
||||
this.word("declare");
|
||||
@@ -178,8 +178,8 @@ function DeclareVariable(node, parent) {
|
||||
}
|
||||
this.word("var");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id.typeAnnotation, node);
|
||||
this.print(node.id);
|
||||
this.print(node.id.typeAnnotation);
|
||||
this.semicolon();
|
||||
}
|
||||
function DeclareExportDeclaration(node) {
|
||||
@@ -205,8 +205,8 @@ function EnumDeclaration(node) {
|
||||
} = node;
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(body, node);
|
||||
this.print(id);
|
||||
this.print(body);
|
||||
}
|
||||
function enumExplicitType(context, name, hasExplicitType) {
|
||||
if (hasExplicitType) {
|
||||
@@ -225,7 +225,7 @@ function enumBody(context, node) {
|
||||
context.indent();
|
||||
context.newline();
|
||||
for (const member of members) {
|
||||
context.print(member, node);
|
||||
context.print(member);
|
||||
context.newline();
|
||||
}
|
||||
if (node.hasUnknownMembers) {
|
||||
@@ -264,19 +264,15 @@ function EnumDefaultedMember(node) {
|
||||
const {
|
||||
id
|
||||
} = 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(",");
|
||||
}
|
||||
function EnumBooleanMember(node) {
|
||||
@@ -291,13 +287,13 @@ function EnumStringMember(node) {
|
||||
function FlowExportDeclaration(node) {
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
this.print(declar, node);
|
||||
this.print(declar);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
} else {
|
||||
this.tokenChar(123);
|
||||
if (node.specifiers.length) {
|
||||
this.space();
|
||||
this.printList(node.specifiers, node);
|
||||
this.printList(node.specifiers);
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(125);
|
||||
@@ -305,7 +301,7 @@ function FlowExportDeclaration(node) {
|
||||
this.space();
|
||||
this.word("from");
|
||||
this.space();
|
||||
this.print(node.source, node);
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
@@ -314,26 +310,26 @@ function ExistsTypeAnnotation() {
|
||||
this.tokenChar(42);
|
||||
}
|
||||
function FunctionTypeAnnotation(node, parent) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.typeParameters);
|
||||
this.tokenChar(40);
|
||||
if (node.this) {
|
||||
this.word("this");
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.this.typeAnnotation, node);
|
||||
this.print(node.this.typeAnnotation);
|
||||
if (node.params.length || node.rest) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
this.printList(node.params, node);
|
||||
this.printList(node.params);
|
||||
if (node.rest) {
|
||||
if (node.params.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
}
|
||||
this.token("...");
|
||||
this.print(node.rest, node);
|
||||
this.print(node.rest);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
const type = parent == null ? void 0 : parent.type;
|
||||
@@ -344,30 +340,30 @@ function FunctionTypeAnnotation(node, parent) {
|
||||
this.token("=>");
|
||||
}
|
||||
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);
|
||||
if (node.name) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
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) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends, node);
|
||||
this.printList(node.extends);
|
||||
}
|
||||
if (node.type === "DeclareClass") {
|
||||
var _node$mixins, _node$implements;
|
||||
@@ -375,17 +371,17 @@ function _interfaceish(node) {
|
||||
this.space();
|
||||
this.word("mixins");
|
||||
this.space();
|
||||
this.printList(node.mixins, node);
|
||||
this.printList(node.mixins);
|
||||
}
|
||||
if ((_node$implements = node.implements) != null && _node$implements.length) {
|
||||
this.space();
|
||||
this.word("implements");
|
||||
this.space();
|
||||
this.printList(node.implements, node);
|
||||
this.printList(node.implements);
|
||||
}
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function _variance(node) {
|
||||
var _node$variance;
|
||||
@@ -403,9 +399,9 @@ function InterfaceDeclaration(node) {
|
||||
this.space();
|
||||
this._interfaceish(node);
|
||||
}
|
||||
function andSeparator() {
|
||||
function andSeparator(occurrenceCount) {
|
||||
this.space();
|
||||
this.tokenChar(38);
|
||||
this.token("&", false, occurrenceCount);
|
||||
this.space();
|
||||
}
|
||||
function InterfaceTypeAnnotation(node) {
|
||||
@@ -415,13 +411,13 @@ function InterfaceTypeAnnotation(node) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(node.extends, node);
|
||||
this.printList(node.extends);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function IntersectionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, node, {
|
||||
this.printJoin(node.types, {
|
||||
separator: andSeparator
|
||||
});
|
||||
}
|
||||
@@ -433,7 +429,7 @@ function EmptyTypeAnnotation() {
|
||||
}
|
||||
function NullableTypeAnnotation(node) {
|
||||
this.tokenChar(63);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function NumberTypeAnnotation() {
|
||||
this.word("number");
|
||||
@@ -446,23 +442,23 @@ function ThisTypeAnnotation() {
|
||||
}
|
||||
function TupleTypeAnnotation(node) {
|
||||
this.tokenChar(91);
|
||||
this.printList(node.types, node);
|
||||
this.printList(node.types);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TypeofTypeAnnotation(node) {
|
||||
this.word("typeof");
|
||||
this.space();
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
}
|
||||
function TypeAlias(node) {
|
||||
this.word("type");
|
||||
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();
|
||||
}
|
||||
function TypeAnnotation(node, parent) {
|
||||
@@ -473,24 +469,24 @@ function TypeAnnotation(node, parent) {
|
||||
} else if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TypeParameterInstantiation(node) {
|
||||
this.tokenChar(60);
|
||||
this.printList(node.params, node, {});
|
||||
this.printList(node.params, {});
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function TypeParameter(node) {
|
||||
this._variance(node);
|
||||
this.word(node.name);
|
||||
if (node.bound) {
|
||||
this.print(node.bound, node);
|
||||
this.print(node.bound);
|
||||
}
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
this.print(node.default);
|
||||
}
|
||||
}
|
||||
function OpaqueType(node) {
|
||||
@@ -498,18 +494,18 @@ function OpaqueType(node) {
|
||||
this.space();
|
||||
this.word("type");
|
||||
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);
|
||||
}
|
||||
if (node.impltype) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.impltype, node);
|
||||
this.print(node.impltype);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
@@ -523,7 +519,7 @@ function ObjectTypeAnnotation(node) {
|
||||
if (props.length) {
|
||||
this.newline();
|
||||
this.space();
|
||||
this.printJoin(props, node, {
|
||||
this.printJoin(props, {
|
||||
addNewlines(leading) {
|
||||
if (leading && !props[0]) return 1;
|
||||
},
|
||||
@@ -559,7 +555,7 @@ function ObjectTypeInternalSlot(node) {
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(91);
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
this.tokenChar(93);
|
||||
this.tokenChar(93);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
@@ -567,14 +563,14 @@ function ObjectTypeInternalSlot(node) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeCallProperty(node) {
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
function ObjectTypeIndexer(node) {
|
||||
if (node.static) {
|
||||
@@ -584,15 +580,15 @@ function ObjectTypeIndexer(node) {
|
||||
this._variance(node);
|
||||
this.tokenChar(91);
|
||||
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);
|
||||
}
|
||||
function ObjectTypeProperty(node) {
|
||||
if (node.proto) {
|
||||
@@ -608,40 +604,40 @@ function ObjectTypeProperty(node) {
|
||||
this.space();
|
||||
}
|
||||
this._variance(node);
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
if (node.optional) this.tokenChar(63);
|
||||
if (!node.method) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
}
|
||||
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);
|
||||
}
|
||||
function SymbolTypeAnnotation() {
|
||||
this.word("symbol");
|
||||
}
|
||||
function orSeparator() {
|
||||
function orSeparator(occurrenceCount) {
|
||||
this.space();
|
||||
this.tokenChar(124);
|
||||
this.token("|", false, occurrenceCount);
|
||||
this.space();
|
||||
}
|
||||
function UnionTypeAnnotation(node) {
|
||||
this.printJoin(node.types, node, {
|
||||
this.printJoin(node.types, {
|
||||
separator: orSeparator
|
||||
});
|
||||
}
|
||||
function TypeCastExpression(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.expression, node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.expression);
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function Variance(node) {
|
||||
@@ -655,18 +651,18 @@ function VoidTypeAnnotation() {
|
||||
this.word("void");
|
||||
}
|
||||
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) {
|
||||
this.token("?.");
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.print(node.indexType, node);
|
||||
this.print(node.indexType);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/flow.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/flow.js.map
generated
vendored
File diff suppressed because one or more lines are too long
52
node_modules/@babel/generator/lib/generators/jsx.js
generated
vendored
52
node_modules/@babel/generator/lib/generators/jsx.js
generated
vendored
@@ -19,41 +19,41 @@ exports.JSXSpreadAttribute = JSXSpreadAttribute;
|
||||
exports.JSXSpreadChild = JSXSpreadChild;
|
||||
exports.JSXText = JSXText;
|
||||
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);
|
||||
}
|
||||
}
|
||||
function JSXIdentifier(node) {
|
||||
this.word(node.name);
|
||||
}
|
||||
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);
|
||||
}
|
||||
function JSXSpreadAttribute(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
this.tokenChar(125);
|
||||
this.print(node.argument);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXExpressionContainer(node) {
|
||||
this.tokenChar(123);
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(125);
|
||||
this.print(node.expression);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXSpreadChild(node) {
|
||||
this.tokenChar(123);
|
||||
this.token("...");
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(125);
|
||||
this.print(node.expression);
|
||||
this.rightBrace(node);
|
||||
}
|
||||
function JSXText(node) {
|
||||
const raw = this.getPossibleRaw(node);
|
||||
@@ -65,51 +65,51 @@ function JSXText(node) {
|
||||
}
|
||||
function JSXElement(node) {
|
||||
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);
|
||||
}
|
||||
function spaceSeparator() {
|
||||
this.space();
|
||||
}
|
||||
function JSXOpeningElement(node) {
|
||||
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) {
|
||||
this.space();
|
||||
this.printJoin(node.attributes, node, {
|
||||
this.printJoin(node.attributes, {
|
||||
separator: spaceSeparator
|
||||
});
|
||||
}
|
||||
if (node.selfClosing) {
|
||||
this.space();
|
||||
this.token("/>");
|
||||
} else {
|
||||
this.tokenChar(62);
|
||||
this.tokenChar(47);
|
||||
}
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function JSXClosingElement(node) {
|
||||
this.token("</");
|
||||
this.print(node.name, node);
|
||||
this.tokenChar(60);
|
||||
this.tokenChar(47);
|
||||
this.print(node.name);
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function JSXEmptyExpression() {
|
||||
this.printInnerComments();
|
||||
}
|
||||
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);
|
||||
}
|
||||
function JSXOpeningFragment() {
|
||||
this.tokenChar(60);
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/jsx.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/jsx.js.map
generated
vendored
File diff suppressed because one or more lines are too long
77
node_modules/@babel/generator/lib/generators/methods.js
generated
vendored
77
node_modules/@babel/generator/lib/generators/methods.js
generated
vendored
@@ -11,43 +11,45 @@ exports._param = _param;
|
||||
exports._parameters = _parameters;
|
||||
exports._params = _params;
|
||||
exports._predicate = _predicate;
|
||||
exports._shouldPrintArrowParamsParens = _shouldPrintArrowParamsParens;
|
||||
var _t = require("@babel/types");
|
||||
var _index = require("../node/index.js");
|
||||
const {
|
||||
isIdentifier
|
||||
} = _t;
|
||||
function _params(node, idNode, parentNode) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.typeParameters);
|
||||
const nameInfo = _getFuncIdName.call(this, idNode, parentNode);
|
||||
if (nameInfo) {
|
||||
this.sourceIdentifierName(nameInfo.name, nameInfo.pos);
|
||||
}
|
||||
this.tokenChar(40);
|
||||
this._parameters(node.params, node);
|
||||
this.tokenChar(41);
|
||||
this._parameters(node.params, ")");
|
||||
const noLineTerminator = node.type === "ArrowFunctionExpression";
|
||||
this.print(node.returnType, node, noLineTerminator);
|
||||
this.print(node.returnType, noLineTerminator);
|
||||
this._noLineTerminator = noLineTerminator;
|
||||
}
|
||||
function _parameters(parameters, parent) {
|
||||
const exit = this.enterForStatementInit(false);
|
||||
function _parameters(parameters, endToken) {
|
||||
const exit = this.enterDelimited();
|
||||
const trailingComma = this.shouldPrintTrailingComma(endToken);
|
||||
const paramLength = parameters.length;
|
||||
for (let i = 0; i < paramLength; i++) {
|
||||
this._param(parameters[i], parent);
|
||||
if (i < parameters.length - 1) {
|
||||
this.tokenChar(44);
|
||||
this._param(parameters[i]);
|
||||
if (trailingComma || i < paramLength - 1) {
|
||||
this.token(",", null, i);
|
||||
this.space();
|
||||
}
|
||||
}
|
||||
this.token(endToken);
|
||||
exit();
|
||||
}
|
||||
function _param(parameter, parent) {
|
||||
this.printJoin(parameter.decorators, parameter);
|
||||
this.print(parameter, parent);
|
||||
function _param(parameter) {
|
||||
this.printJoin(parameter.decorators);
|
||||
this.print(parameter);
|
||||
if (parameter.optional) {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
this.print(parameter.typeAnnotation, parameter);
|
||||
this.print(parameter.typeAnnotation);
|
||||
}
|
||||
function _methodHead(node) {
|
||||
const kind = node.kind;
|
||||
@@ -67,10 +69,10 @@ function _methodHead(node) {
|
||||
}
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
this.print(key, node);
|
||||
this.print(key);
|
||||
this.tokenChar(93);
|
||||
} else {
|
||||
this.print(key, node);
|
||||
this.print(key);
|
||||
}
|
||||
if (node.optional) {
|
||||
this.tokenChar(63);
|
||||
@@ -83,23 +85,27 @@ function _predicate(node, noLineTerminatorAfter) {
|
||||
this.tokenChar(58);
|
||||
}
|
||||
this.space();
|
||||
this.print(node.predicate, node, noLineTerminatorAfter);
|
||||
this.print(node.predicate, noLineTerminatorAfter);
|
||||
}
|
||||
}
|
||||
function _functionHead(node, parent) {
|
||||
if (node.async) {
|
||||
this.word("async");
|
||||
this._endsWithInnerRaw = false;
|
||||
if (!this.format.preserveFormat) {
|
||||
this._endsWithInnerRaw = false;
|
||||
}
|
||||
this.space();
|
||||
}
|
||||
this.word("function");
|
||||
if (node.generator) {
|
||||
this._endsWithInnerRaw = false;
|
||||
if (!this.format.preserveFormat) {
|
||||
this._endsWithInnerRaw = false;
|
||||
}
|
||||
this.tokenChar(42);
|
||||
}
|
||||
this.space();
|
||||
if (node.id) {
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
}
|
||||
this._params(node, node.id, parent);
|
||||
if (node.type !== "TSDeclareFunction") {
|
||||
@@ -109,18 +115,17 @@ function _functionHead(node, parent) {
|
||||
function FunctionExpression(node, parent) {
|
||||
this._functionHead(node, parent);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function ArrowFunctionExpression(node, parent) {
|
||||
if (node.async) {
|
||||
this.word("async", true);
|
||||
this.space();
|
||||
}
|
||||
let firstParam;
|
||||
if (!this.format.retainLines && node.params.length === 1 && isIdentifier(firstParam = node.params[0]) && !hasTypesOrComments(node, firstParam)) {
|
||||
this.print(firstParam, node, true);
|
||||
} else {
|
||||
if (this._shouldPrintArrowParamsParens(node)) {
|
||||
this._params(node, undefined, parent);
|
||||
} else {
|
||||
this.print(node.params[0], true);
|
||||
}
|
||||
this._predicate(node, true);
|
||||
this.space();
|
||||
@@ -128,11 +133,27 @@ function ArrowFunctionExpression(node, parent) {
|
||||
this.token("=>");
|
||||
this.space();
|
||||
this.tokenContext |= _index.TokenContext.arrowBody;
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function hasTypesOrComments(node, param) {
|
||||
var _param$leadingComment, _param$trailingCommen;
|
||||
return !!(node.typeParameters || node.returnType || node.predicate || param.typeAnnotation || param.optional || (_param$leadingComment = param.leadingComments) != null && _param$leadingComment.length || (_param$trailingCommen = param.trailingComments) != null && _param$trailingCommen.length);
|
||||
function _shouldPrintArrowParamsParens(node) {
|
||||
var _firstParam$leadingCo, _firstParam$trailingC;
|
||||
if (node.params.length !== 1) return true;
|
||||
if (node.typeParameters || node.returnType || node.predicate) {
|
||||
return true;
|
||||
}
|
||||
const firstParam = node.params[0];
|
||||
if (!isIdentifier(firstParam) || firstParam.typeAnnotation || firstParam.optional || (_firstParam$leadingCo = firstParam.leadingComments) != null && _firstParam$leadingCo.length || (_firstParam$trailingC = firstParam.trailingComments) != null && _firstParam$trailingC.length) {
|
||||
return true;
|
||||
}
|
||||
if (this.tokenMap) {
|
||||
if (node.loc == null) return true;
|
||||
if (this.tokenMap.findMatching(node, "(") !== null) return true;
|
||||
const arrowToken = this.tokenMap.findMatching(node, "=>");
|
||||
if ((arrowToken == null ? void 0 : arrowToken.loc) == null) return true;
|
||||
return arrowToken.loc.start.line !== node.loc.start.line;
|
||||
}
|
||||
if (this.format.retainLines) return true;
|
||||
return false;
|
||||
}
|
||||
function _getFuncIdName(idNode, parent) {
|
||||
let id = idNode;
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/methods.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/methods.js.map
generated
vendored
File diff suppressed because one or more lines are too long
74
node_modules/@babel/generator/lib/generators/modules.js
generated
vendored
74
node_modules/@babel/generator/lib/generators/modules.js
generated
vendored
@@ -31,31 +31,31 @@ function ImportSpecifier(node) {
|
||||
this.word(node.importKind);
|
||||
this.space();
|
||||
}
|
||||
this.print(node.imported, node);
|
||||
this.print(node.imported);
|
||||
if (node.local && node.local.name !== node.imported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
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);
|
||||
}
|
||||
function ExportSpecifier(node) {
|
||||
if (node.exportKind === "type") {
|
||||
this.word("type");
|
||||
this.space();
|
||||
}
|
||||
this.print(node.local, node);
|
||||
this.print(node.local);
|
||||
if (node.exported && node.local.name !== node.exported.name) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.exported, node);
|
||||
this.print(node.exported);
|
||||
}
|
||||
}
|
||||
function ExportNamespaceSpecifier(node) {
|
||||
@@ -63,10 +63,10 @@ function ExportNamespaceSpecifier(node) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.exported, node);
|
||||
this.print(node.exported);
|
||||
}
|
||||
let warningShown = false;
|
||||
function _printAttributes(node) {
|
||||
function _printAttributes(node, hasPreviousBrace) {
|
||||
const {
|
||||
importAttributesKeyword
|
||||
} = this.format;
|
||||
@@ -88,14 +88,17 @@ Please specify the "importAttributesKeyword" generator option, whose value can b
|
||||
this.word(useAssertKeyword ? "assert" : "with");
|
||||
this.space();
|
||||
if (!useAssertKeyword && importAttributesKeyword !== "with") {
|
||||
this.printList(attributes || assertions, node);
|
||||
this.printList(attributes || assertions);
|
||||
return;
|
||||
}
|
||||
this.tokenChar(123);
|
||||
const occurrenceCount = hasPreviousBrace ? 1 : 0;
|
||||
this.token("{", null, occurrenceCount);
|
||||
this.space();
|
||||
this.printList(attributes || assertions, node);
|
||||
this.printList(attributes || assertions, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma("}")
|
||||
});
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
this.token("}", null, occurrenceCount);
|
||||
}
|
||||
function ExportAllDeclaration(node) {
|
||||
var _node$attributes, _node$assertions;
|
||||
@@ -110,17 +113,17 @@ function ExportAllDeclaration(node) {
|
||||
this.word("from");
|
||||
this.space();
|
||||
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);
|
||||
this._printAttributes(node, false);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
function maybePrintDecoratorsBeforeExport(printer, node) {
|
||||
if (isClassDeclaration(node.declaration) && printer._shouldPrintDecoratorsBeforeExport(node)) {
|
||||
printer.printJoin(node.declaration.decorators, node);
|
||||
printer.printJoin(node.declaration.decorators);
|
||||
}
|
||||
}
|
||||
function ExportNamedDeclaration(node) {
|
||||
@@ -129,7 +132,7 @@ function ExportNamedDeclaration(node) {
|
||||
this.space();
|
||||
if (node.declaration) {
|
||||
const declar = node.declaration;
|
||||
this.print(declar, node);
|
||||
this.print(declar);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
} else {
|
||||
if (node.exportKind === "type") {
|
||||
@@ -142,7 +145,7 @@ function ExportNamedDeclaration(node) {
|
||||
const first = specifiers[0];
|
||||
if (isExportDefaultSpecifier(first) || isExportNamespaceSpecifier(first)) {
|
||||
hasSpecial = true;
|
||||
this.print(specifiers.shift(), node);
|
||||
this.print(specifiers.shift());
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
@@ -151,11 +154,15 @@ function ExportNamedDeclaration(node) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hasBrace = false;
|
||||
if (specifiers.length || !specifiers.length && !hasSpecial) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
if (specifiers.length) {
|
||||
this.space();
|
||||
this.printList(specifiers, node);
|
||||
this.printList(specifiers, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma("}")
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(125);
|
||||
@@ -166,11 +173,11 @@ function ExportNamedDeclaration(node) {
|
||||
this.word("from");
|
||||
this.space();
|
||||
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);
|
||||
this._printAttributes(node, hasBrace);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
this.print(node.source);
|
||||
}
|
||||
}
|
||||
this.semicolon();
|
||||
@@ -185,7 +192,7 @@ function ExportDefaultDeclaration(node) {
|
||||
this.space();
|
||||
this.tokenContext |= _index.TokenContext.exportDefault;
|
||||
const declar = node.declaration;
|
||||
this.print(declar, node);
|
||||
this.print(declar);
|
||||
if (!isStatement(declar)) this.semicolon();
|
||||
}
|
||||
function ImportDeclaration(node) {
|
||||
@@ -211,7 +218,7 @@ function ImportDeclaration(node) {
|
||||
while (hasSpecifiers) {
|
||||
const first = specifiers[0];
|
||||
if (isImportDefaultSpecifier(first) || isImportNamespaceSpecifier(first)) {
|
||||
this.print(specifiers.shift(), node);
|
||||
this.print(specifiers.shift());
|
||||
if (specifiers.length) {
|
||||
this.tokenChar(44);
|
||||
this.space();
|
||||
@@ -220,13 +227,18 @@ function ImportDeclaration(node) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let hasBrace = false;
|
||||
if (specifiers.length) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
this.space();
|
||||
this.printList(specifiers, node);
|
||||
this.printList(specifiers, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma("}")
|
||||
});
|
||||
this.space();
|
||||
this.tokenChar(125);
|
||||
} else if (isTypeKind && !hasSpecifiers) {
|
||||
hasBrace = true;
|
||||
this.tokenChar(123);
|
||||
this.tokenChar(125);
|
||||
}
|
||||
@@ -236,11 +248,11 @@ function ImportDeclaration(node) {
|
||||
this.space();
|
||||
}
|
||||
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);
|
||||
this._printAttributes(node, hasBrace);
|
||||
} else {
|
||||
this.print(node.source, node);
|
||||
this.print(node.source);
|
||||
}
|
||||
this.semicolon();
|
||||
}
|
||||
@@ -255,7 +267,7 @@ function ImportNamespaceSpecifier(node) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(node.local, node);
|
||||
this.print(node.local);
|
||||
}
|
||||
function ImportExpression(node) {
|
||||
this.word("import");
|
||||
@@ -264,11 +276,11 @@ function ImportExpression(node) {
|
||||
this.word(node.phase);
|
||||
}
|
||||
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);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
}
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/modules.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/modules.js.map
generated
vendored
File diff suppressed because one or more lines are too long
80
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
80
node_modules/@babel/generator/lib/generators/statements.js
generated
vendored
@@ -33,7 +33,7 @@ function WithStatement(node) {
|
||||
this.word("with");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.object, node);
|
||||
this.print(node.object);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
@@ -41,7 +41,7 @@ function IfStatement(node) {
|
||||
this.word("if");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
const needsBlock = node.alternate && isIfStatement(getLastStatement(node.consequent));
|
||||
@@ -50,7 +50,7 @@ function IfStatement(node) {
|
||||
this.newline();
|
||||
this.indent();
|
||||
}
|
||||
this.printAndIndentOnComments(node.consequent, node);
|
||||
this.printAndIndentOnComments(node.consequent);
|
||||
if (needsBlock) {
|
||||
this.dedent();
|
||||
this.newline();
|
||||
@@ -60,7 +60,7 @@ function IfStatement(node) {
|
||||
if (this.endsWith(125)) this.space();
|
||||
this.word("else");
|
||||
this.space();
|
||||
this.printAndIndentOnComments(node.alternate, node);
|
||||
this.printAndIndentOnComments(node.alternate);
|
||||
}
|
||||
}
|
||||
function getLastStatement(statement) {
|
||||
@@ -77,20 +77,20 @@ function ForStatement(node) {
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
{
|
||||
const exit = this.enterForStatementInit(true);
|
||||
const exit = this.enterForStatementInit();
|
||||
this.tokenContext |= _index.TokenContext.forHead;
|
||||
this.print(node.init, node);
|
||||
this.print(node.init);
|
||||
exit();
|
||||
}
|
||||
this.tokenChar(59);
|
||||
if (node.test) {
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
}
|
||||
this.tokenChar(59);
|
||||
this.token(";", false, 1);
|
||||
if (node.update) {
|
||||
this.space();
|
||||
this.print(node.update, node);
|
||||
this.print(node.update);
|
||||
}
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
@@ -99,7 +99,7 @@ function WhileStatement(node) {
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
@@ -114,15 +114,15 @@ function ForXStatement(node) {
|
||||
this.noIndentInnerCommentsHere();
|
||||
this.tokenChar(40);
|
||||
{
|
||||
const exit = isForOf ? null : this.enterForStatementInit(true);
|
||||
const exit = isForOf ? null : this.enterForStatementInit();
|
||||
this.tokenContext |= isForOf ? _index.TokenContext.forOfHead : _index.TokenContext.forInHead;
|
||||
this.print(node.left, node);
|
||||
this.print(node.left);
|
||||
exit == null || exit();
|
||||
}
|
||||
this.space();
|
||||
this.word(isForOf ? "of" : "in");
|
||||
this.space();
|
||||
this.print(node.right, node);
|
||||
this.print(node.right);
|
||||
this.tokenChar(41);
|
||||
this.printBlock(node);
|
||||
}
|
||||
@@ -131,59 +131,59 @@ const ForOfStatement = exports.ForOfStatement = ForXStatement;
|
||||
function DoWhileStatement(node) {
|
||||
this.word("do");
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
this.space();
|
||||
this.word("while");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(41);
|
||||
this.semicolon();
|
||||
}
|
||||
function printStatementAfterKeyword(printer, node, parent, isLabel) {
|
||||
function printStatementAfterKeyword(printer, node) {
|
||||
if (node) {
|
||||
printer.space();
|
||||
printer.printTerminatorless(node, parent, isLabel);
|
||||
printer.printTerminatorless(node);
|
||||
}
|
||||
printer.semicolon();
|
||||
}
|
||||
function BreakStatement(node) {
|
||||
this.word("break");
|
||||
printStatementAfterKeyword(this, node.label, node, true);
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ContinueStatement(node) {
|
||||
this.word("continue");
|
||||
printStatementAfterKeyword(this, node.label, node, true);
|
||||
printStatementAfterKeyword(this, node.label);
|
||||
}
|
||||
function ReturnStatement(node) {
|
||||
this.word("return");
|
||||
printStatementAfterKeyword(this, node.argument, node, false);
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
function ThrowStatement(node) {
|
||||
this.word("throw");
|
||||
printStatementAfterKeyword(this, node.argument, node, false);
|
||||
printStatementAfterKeyword(this, node.argument);
|
||||
}
|
||||
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);
|
||||
}
|
||||
function TryStatement(node) {
|
||||
this.word("try");
|
||||
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);
|
||||
}
|
||||
if (node.finalizer) {
|
||||
this.space();
|
||||
this.word("finally");
|
||||
this.space();
|
||||
this.print(node.finalizer, node);
|
||||
this.print(node.finalizer);
|
||||
}
|
||||
}
|
||||
function CatchClause(node) {
|
||||
@@ -191,22 +191,22 @@ function CatchClause(node) {
|
||||
this.space();
|
||||
if (node.param) {
|
||||
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);
|
||||
}
|
||||
function SwitchStatement(node) {
|
||||
this.word("switch");
|
||||
this.space();
|
||||
this.tokenChar(40);
|
||||
this.print(node.discriminant, node);
|
||||
this.print(node.discriminant);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
this.tokenChar(123);
|
||||
this.printSequence(node.cases, node, {
|
||||
this.printSequence(node.cases, {
|
||||
indent: true,
|
||||
addNewlines(leading, cas) {
|
||||
if (!leading && node.cases[node.cases.length - 1] === cas) return -1;
|
||||
@@ -218,7 +218,7 @@ function SwitchCase(node) {
|
||||
if (node.test) {
|
||||
this.word("case");
|
||||
this.space();
|
||||
this.print(node.test, node);
|
||||
this.print(node.test);
|
||||
this.tokenChar(58);
|
||||
} else {
|
||||
this.word("default");
|
||||
@@ -226,7 +226,7 @@ function SwitchCase(node) {
|
||||
}
|
||||
if (node.consequent.length) {
|
||||
this.newline();
|
||||
this.printSequence(node.consequent, node, {
|
||||
this.printSequence(node.consequent, {
|
||||
indent: true
|
||||
});
|
||||
}
|
||||
@@ -259,9 +259,9 @@ function VariableDeclaration(node, parent) {
|
||||
}
|
||||
}
|
||||
}
|
||||
this.printList(node.declarations, node, {
|
||||
separator: hasInits ? function () {
|
||||
this.tokenChar(44);
|
||||
this.printList(node.declarations, {
|
||||
separator: hasInits ? function (occurrenceCount) {
|
||||
this.token(",", false, occurrenceCount);
|
||||
this.newline();
|
||||
} : undefined,
|
||||
indent: node.declarations.length > 1 ? true : false
|
||||
@@ -276,14 +276,14 @@ function VariableDeclaration(node, parent) {
|
||||
this.semicolon();
|
||||
}
|
||||
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) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.init, node);
|
||||
this.print(node.init);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/statements.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/statements.js.map
generated
vendored
File diff suppressed because one or more lines are too long
12
node_modules/@babel/generator/lib/generators/template-literals.js
generated
vendored
12
node_modules/@babel/generator/lib/generators/template-literals.js
generated
vendored
@@ -7,9 +7,9 @@ exports.TaggedTemplateExpression = TaggedTemplateExpression;
|
||||
exports.TemplateElement = TemplateElement;
|
||||
exports.TemplateLiteral = TemplateLiteral;
|
||||
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);
|
||||
}
|
||||
function TemplateElement() {
|
||||
throw new Error("TemplateElement printing is handled in TemplateLiteral");
|
||||
@@ -21,8 +21,12 @@ function TemplateLiteral(node) {
|
||||
partRaw += quasis[i].value.raw;
|
||||
if (i + 1 < quasis.length) {
|
||||
this.token(partRaw + "${", true);
|
||||
this.print(node.expressions[i], node);
|
||||
this.print(node.expressions[i]);
|
||||
partRaw = "}";
|
||||
if (this.tokenMap) {
|
||||
const token = this.tokenMap.findMatching(node, "}", i);
|
||||
if (token) this._catchUpTo(token.loc.start);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.token(partRaw + "`", true);
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/template-literals.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/template-literals.js.map
generated
vendored
@@ -1 +1 @@
|
||||
{"version":3,"names":["TaggedTemplateExpression","node","print","tag","typeParameters","quasi","TemplateElement","Error","TemplateLiteral","quasis","partRaw","i","length","value","raw","token","expressions"],"sources":["../../src/generators/template-literals.ts"],"sourcesContent":["import type Printer from \"../printer.ts\";\nimport type * as t from \"@babel/types\";\n\nexport function TaggedTemplateExpression(\n this: Printer,\n node: t.TaggedTemplateExpression,\n) {\n this.print(node.tag, node);\n this.print(node.typeParameters, node); // TS\n this.print(node.quasi, node);\n}\n\nexport function TemplateElement(this: Printer) {\n throw new Error(\"TemplateElement printing is handled in TemplateLiteral\");\n}\n\nexport function TemplateLiteral(this: Printer, node: t.TemplateLiteral) {\n const quasis = node.quasis;\n\n let partRaw = \"`\";\n\n for (let i = 0; i < quasis.length; i++) {\n partRaw += quasis[i].value.raw;\n\n if (i + 1 < quasis.length) {\n this.token(partRaw + \"${\", true);\n this.print(node.expressions[i], node);\n partRaw = \"}\";\n }\n }\n\n this.token(partRaw + \"`\", true);\n}\n"],"mappings":";;;;;;;;AAGO,SAASA,wBAAwBA,CAEtCC,IAAgC,EAChC;EACA,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,GAAG,EAAEF,IAAI,CAAC;EAC1B,IAAI,CAACC,KAAK,CAACD,IAAI,CAACG,cAAc,EAAEH,IAAI,CAAC;EACrC,IAAI,CAACC,KAAK,CAACD,IAAI,CAACI,KAAK,EAAEJ,IAAI,CAAC;AAC9B;AAEO,SAASK,eAAeA,CAAA,EAAgB;EAC7C,MAAM,IAAIC,KAAK,CAAC,wDAAwD,CAAC;AAC3E;AAEO,SAASC,eAAeA,CAAgBP,IAAuB,EAAE;EACtE,MAAMQ,MAAM,GAAGR,IAAI,CAACQ,MAAM;EAE1B,IAAIC,OAAO,GAAG,GAAG;EAEjB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;IACtCD,OAAO,IAAID,MAAM,CAACE,CAAC,CAAC,CAACE,KAAK,CAACC,GAAG;IAE9B,IAAIH,CAAC,GAAG,CAAC,GAAGF,MAAM,CAACG,MAAM,EAAE;MACzB,IAAI,CAACG,KAAK,CAACL,OAAO,GAAG,IAAI,EAAE,IAAI,CAAC;MAChC,IAAI,CAACR,KAAK,CAACD,IAAI,CAACe,WAAW,CAACL,CAAC,CAAC,EAAEV,IAAI,CAAC;MACrCS,OAAO,GAAG,GAAG;IACf;EACF;EAEA,IAAI,CAACK,KAAK,CAACL,OAAO,GAAG,GAAG,EAAE,IAAI,CAAC;AACjC","ignoreList":[]}
|
||||
{"version":3,"names":["TaggedTemplateExpression","node","print","tag","typeParameters","quasi","TemplateElement","Error","TemplateLiteral","quasis","partRaw","i","length","value","raw","token","expressions","tokenMap","findMatching","_catchUpTo","loc","start"],"sources":["../../src/generators/template-literals.ts"],"sourcesContent":["import type Printer from \"../printer.ts\";\nimport type * as t from \"@babel/types\";\n\nexport function TaggedTemplateExpression(\n this: Printer,\n node: t.TaggedTemplateExpression,\n) {\n this.print(node.tag);\n this.print(node.typeParameters); // TS\n this.print(node.quasi);\n}\n\nexport function TemplateElement(this: Printer) {\n throw new Error(\"TemplateElement printing is handled in TemplateLiteral\");\n}\n\nexport function TemplateLiteral(this: Printer, node: t.TemplateLiteral) {\n const quasis = node.quasis;\n\n let partRaw = \"`\";\n\n for (let i = 0; i < quasis.length; i++) {\n partRaw += quasis[i].value.raw;\n\n if (i + 1 < quasis.length) {\n this.token(partRaw + \"${\", true);\n this.print(node.expressions[i]);\n partRaw = \"}\";\n\n // In Babel 7 we have indivirual tokens for ${ and }, so the automatic\n // catchup logic does not work. Manually look for those tokens.\n if (!process.env.BABEL_8_BREAKING && this.tokenMap) {\n const token = this.tokenMap.findMatching(node, \"}\", i);\n if (token) this._catchUpTo(token.loc.start);\n }\n }\n }\n\n this.token(partRaw + \"`\", true);\n}\n"],"mappings":";;;;;;;;AAGO,SAASA,wBAAwBA,CAEtCC,IAAgC,EAChC;EACA,IAAI,CAACC,KAAK,CAACD,IAAI,CAACE,GAAG,CAAC;EACpB,IAAI,CAACD,KAAK,CAACD,IAAI,CAACG,cAAc,CAAC;EAC/B,IAAI,CAACF,KAAK,CAACD,IAAI,CAACI,KAAK,CAAC;AACxB;AAEO,SAASC,eAAeA,CAAA,EAAgB;EAC7C,MAAM,IAAIC,KAAK,CAAC,wDAAwD,CAAC;AAC3E;AAEO,SAASC,eAAeA,CAAgBP,IAAuB,EAAE;EACtE,MAAMQ,MAAM,GAAGR,IAAI,CAACQ,MAAM;EAE1B,IAAIC,OAAO,GAAG,GAAG;EAEjB,KAAK,IAAIC,CAAC,GAAG,CAAC,EAAEA,CAAC,GAAGF,MAAM,CAACG,MAAM,EAAED,CAAC,EAAE,EAAE;IACtCD,OAAO,IAAID,MAAM,CAACE,CAAC,CAAC,CAACE,KAAK,CAACC,GAAG;IAE9B,IAAIH,CAAC,GAAG,CAAC,GAAGF,MAAM,CAACG,MAAM,EAAE;MACzB,IAAI,CAACG,KAAK,CAACL,OAAO,GAAG,IAAI,EAAE,IAAI,CAAC;MAChC,IAAI,CAACR,KAAK,CAACD,IAAI,CAACe,WAAW,CAACL,CAAC,CAAC,CAAC;MAC/BD,OAAO,GAAG,GAAG;MAIb,IAAqC,IAAI,CAACO,QAAQ,EAAE;QAClD,MAAMF,KAAK,GAAG,IAAI,CAACE,QAAQ,CAACC,YAAY,CAACjB,IAAI,EAAE,GAAG,EAAEU,CAAC,CAAC;QACtD,IAAII,KAAK,EAAE,IAAI,CAACI,UAAU,CAACJ,KAAK,CAACK,GAAG,CAACC,KAAK,CAAC;MAC7C;IACF;EACF;EAEA,IAAI,CAACN,KAAK,CAACL,OAAO,GAAG,GAAG,EAAE,IAAI,CAAC;AACjC","ignoreList":[]}
|
||||
66
node_modules/@babel/generator/lib/generators/types.js
generated
vendored
66
node_modules/@babel/generator/lib/generators/types.js
generated
vendored
@@ -23,33 +23,50 @@ exports.SpreadElement = exports.RestElement = RestElement;
|
||||
exports.StringLiteral = StringLiteral;
|
||||
exports.TopicReference = TopicReference;
|
||||
exports.TupleExpression = TupleExpression;
|
||||
exports._getRawIdentifier = _getRawIdentifier;
|
||||
var _t = require("@babel/types");
|
||||
var _jsesc = require("jsesc");
|
||||
const {
|
||||
isAssignmentPattern,
|
||||
isIdentifier
|
||||
} = _t;
|
||||
let lastRawIdentNode = null;
|
||||
let lastRawIdentResult = "";
|
||||
function _getRawIdentifier(node) {
|
||||
if (node === lastRawIdentNode) return lastRawIdentResult;
|
||||
lastRawIdentNode = node;
|
||||
const {
|
||||
name
|
||||
} = node;
|
||||
const token = this.tokenMap.find(node, tok => tok.value === name);
|
||||
if (token) {
|
||||
lastRawIdentResult = this._originalCode.slice(token.start, token.end);
|
||||
return lastRawIdentResult;
|
||||
}
|
||||
return lastRawIdentResult = node.name;
|
||||
}
|
||||
function Identifier(node) {
|
||||
var _node$loc;
|
||||
this.sourceIdentifierName(((_node$loc = node.loc) == null ? void 0 : _node$loc.identifierName) || node.name);
|
||||
this.word(node.name);
|
||||
this.word(this.tokenMap ? this._getRawIdentifier(node) : node.name);
|
||||
}
|
||||
function ArgumentPlaceholder() {
|
||||
this.tokenChar(63);
|
||||
}
|
||||
function RestElement(node) {
|
||||
this.token("...");
|
||||
this.print(node.argument, node);
|
||||
this.print(node.argument);
|
||||
}
|
||||
function ObjectExpression(node) {
|
||||
const props = node.properties;
|
||||
this.tokenChar(123);
|
||||
if (props.length) {
|
||||
const exit = this.enterForStatementInit(false);
|
||||
const exit = this.enterDelimited();
|
||||
this.space();
|
||||
this.printList(props, node, {
|
||||
this.printList(props, {
|
||||
indent: true,
|
||||
statement: true
|
||||
statement: true,
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma("}")
|
||||
});
|
||||
this.space();
|
||||
exit();
|
||||
@@ -58,44 +75,46 @@ function ObjectExpression(node) {
|
||||
this.tokenChar(125);
|
||||
}
|
||||
function ObjectMethod(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.printJoin(node.decorators);
|
||||
this._methodHead(node);
|
||||
this.space();
|
||||
this.print(node.body, node);
|
||||
this.print(node.body);
|
||||
}
|
||||
function ObjectProperty(node) {
|
||||
this.printJoin(node.decorators, node);
|
||||
this.printJoin(node.decorators);
|
||||
if (node.computed) {
|
||||
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) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(node.value, node);
|
||||
this.print(node.value);
|
||||
}
|
||||
function ArrayExpression(node) {
|
||||
const elems = node.elements;
|
||||
const len = elems.length;
|
||||
this.tokenChar(91);
|
||||
const exit = this.enterForStatementInit(false);
|
||||
const exit = this.enterDelimited();
|
||||
for (let i = 0; i < elems.length; i++) {
|
||||
const elem = elems[i];
|
||||
if (elem) {
|
||||
if (i > 0) this.space();
|
||||
this.print(elem, node);
|
||||
if (i < len - 1) this.tokenChar(44);
|
||||
this.print(elem);
|
||||
if (i < len - 1 || this.shouldPrintTrailingComma("]")) {
|
||||
this.token(",", false, i);
|
||||
}
|
||||
} else {
|
||||
this.tokenChar(44);
|
||||
this.token(",", false, i);
|
||||
}
|
||||
}
|
||||
exit();
|
||||
@@ -119,9 +138,10 @@ function RecordExpression(node) {
|
||||
this.token(startToken);
|
||||
if (props.length) {
|
||||
this.space();
|
||||
this.printList(props, node, {
|
||||
this.printList(props, {
|
||||
indent: true,
|
||||
statement: true
|
||||
statement: true,
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma(endToken)
|
||||
});
|
||||
this.space();
|
||||
}
|
||||
@@ -148,8 +168,10 @@ function TupleExpression(node) {
|
||||
const elem = elems[i];
|
||||
if (elem) {
|
||||
if (i > 0) this.space();
|
||||
this.print(elem, node);
|
||||
if (i < len - 1) this.tokenChar(44);
|
||||
this.print(elem);
|
||||
if (i < len - 1 || this.shouldPrintTrailingComma(endToken)) {
|
||||
this.token(",", false, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
this.token(endToken);
|
||||
@@ -217,10 +239,10 @@ function TopicReference() {
|
||||
}
|
||||
}
|
||||
function PipelineTopicExpression(node) {
|
||||
this.print(node.expression, node);
|
||||
this.print(node.expression);
|
||||
}
|
||||
function PipelineBareFunction(node) {
|
||||
this.print(node.callee, node);
|
||||
this.print(node.callee);
|
||||
}
|
||||
function PipelinePrimaryTopicReference() {
|
||||
this.tokenChar(35);
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/types.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/types.js.map
generated
vendored
File diff suppressed because one or more lines are too long
302
node_modules/@babel/generator/lib/generators/typescript.js
generated
vendored
302
node_modules/@babel/generator/lib/generators/typescript.js
generated
vendored
@@ -9,6 +9,7 @@ exports.TSSatisfiesExpression = exports.TSAsExpression = TSTypeExpression;
|
||||
exports.TSBigIntKeyword = TSBigIntKeyword;
|
||||
exports.TSBooleanKeyword = TSBooleanKeyword;
|
||||
exports.TSCallSignatureDeclaration = TSCallSignatureDeclaration;
|
||||
exports.TSInterfaceHeritage = exports.TSExpressionWithTypeArguments = exports.TSClassImplements = TSClassImplements;
|
||||
exports.TSConditionalType = TSConditionalType;
|
||||
exports.TSConstructSignatureDeclaration = TSConstructSignatureDeclaration;
|
||||
exports.TSConstructorType = TSConstructorType;
|
||||
@@ -17,7 +18,6 @@ exports.TSDeclareMethod = TSDeclareMethod;
|
||||
exports.TSEnumDeclaration = TSEnumDeclaration;
|
||||
exports.TSEnumMember = TSEnumMember;
|
||||
exports.TSExportAssignment = TSExportAssignment;
|
||||
exports.TSExpressionWithTypeArguments = TSExpressionWithTypeArguments;
|
||||
exports.TSExternalModuleReference = TSExternalModuleReference;
|
||||
exports.TSFunctionType = TSFunctionType;
|
||||
exports.TSImportEqualsDeclaration = TSImportEqualsDeclaration;
|
||||
@@ -70,19 +70,22 @@ exports.tsPrintClassMemberModifiers = tsPrintClassMemberModifiers;
|
||||
exports.tsPrintFunctionOrConstructorType = tsPrintFunctionOrConstructorType;
|
||||
exports.tsPrintPropertyOrMethodName = tsPrintPropertyOrMethodName;
|
||||
exports.tsPrintSignatureDeclarationBase = tsPrintSignatureDeclarationBase;
|
||||
exports.tsPrintTypeLiteralOrInterfaceBody = tsPrintTypeLiteralOrInterfaceBody;
|
||||
function TSTypeAnnotation(node) {
|
||||
this.tokenChar(58);
|
||||
function TSTypeAnnotation(node, parent) {
|
||||
this.token((parent.type === "TSFunctionType" || parent.type === "TSConstructorType") && parent.typeAnnotation === node ? "=>" : ":");
|
||||
this.space();
|
||||
if (node.optional) this.tokenChar(63);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
}
|
||||
function TSTypeParameterInstantiation(node, parent) {
|
||||
this.tokenChar(60);
|
||||
this.printList(node.params, node, {});
|
||||
if (parent.type === "ArrowFunctionExpression" && node.params.length === 1) {
|
||||
this.tokenChar(44);
|
||||
let printTrailingSeparator = parent.type === "ArrowFunctionExpression" && node.params.length === 1;
|
||||
if (this.tokenMap && node.start != null && node.end != null) {
|
||||
printTrailingSeparator && (printTrailingSeparator = !!this.tokenMap.find(node, t => this.tokenMap.matchesOriginal(t, ",")));
|
||||
printTrailingSeparator || (printTrailingSeparator = this.shouldPrintTrailingComma(">"));
|
||||
}
|
||||
this.printList(node.params, {
|
||||
printTrailingSeparator
|
||||
});
|
||||
this.tokenChar(62);
|
||||
}
|
||||
function TSTypeParameter(node) {
|
||||
@@ -99,13 +102,13 @@ function TSTypeParameter(node) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.print(node.constraint, node);
|
||||
this.print(node.constraint);
|
||||
}
|
||||
if (node.default) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.default, node);
|
||||
this.print(node.default);
|
||||
}
|
||||
}
|
||||
function TSParameterProperty(node) {
|
||||
@@ -125,26 +128,37 @@ function TSDeclareFunction(node, parent) {
|
||||
this.space();
|
||||
}
|
||||
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);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function maybePrintTrailingCommaOrSemicolon(printer, node) {
|
||||
if (!printer.tokenMap || !node.start || !node.end) {
|
||||
printer.semicolon();
|
||||
return;
|
||||
}
|
||||
if (printer.tokenMap.endMatches(node, ",")) {
|
||||
printer.token(",");
|
||||
} else if (printer.tokenMap.endMatches(node, ";")) {
|
||||
printer.semicolon();
|
||||
}
|
||||
}
|
||||
function TSConstructSignatureDeclaration(node) {
|
||||
this.word("new");
|
||||
this.space();
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.tokenChar(59);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSPropertySignature(node) {
|
||||
const {
|
||||
@@ -155,14 +169,14 @@ function TSPropertySignature(node) {
|
||||
this.space();
|
||||
}
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.tokenChar(59);
|
||||
this.print(node.typeAnnotation);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function tsPrintPropertyOrMethodName(node) {
|
||||
if (node.computed) {
|
||||
this.tokenChar(91);
|
||||
}
|
||||
this.print(node.key, node);
|
||||
this.print(node.key);
|
||||
if (node.computed) {
|
||||
this.tokenChar(93);
|
||||
}
|
||||
@@ -180,7 +194,7 @@ function TSMethodSignature(node) {
|
||||
}
|
||||
this.tsPrintPropertyOrMethodName(node);
|
||||
this.tsPrintSignatureDeclarationBase(node);
|
||||
this.tokenChar(59);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSIndexSignature(node) {
|
||||
const {
|
||||
@@ -196,10 +210,9 @@ function TSIndexSignature(node) {
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this._parameters(node.parameters, node);
|
||||
this.tokenChar(93);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.tokenChar(59);
|
||||
this._parameters(node.parameters, "]");
|
||||
this.print(node.typeAnnotation);
|
||||
maybePrintTrailingCommaOrSemicolon(this, node);
|
||||
}
|
||||
function TSAnyKeyword() {
|
||||
this.word("any");
|
||||
@@ -260,19 +273,16 @@ function tsPrintFunctionOrConstructorType(node) {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters, node);
|
||||
this.print(typeParameters);
|
||||
this.tokenChar(40);
|
||||
this._parameters(parameters, node);
|
||||
this.tokenChar(41);
|
||||
this.space();
|
||||
this.token("=>");
|
||||
this._parameters(parameters, ")");
|
||||
this.space();
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType.typeAnnotation, node);
|
||||
this.print(returnType);
|
||||
}
|
||||
function TSTypeReference(node) {
|
||||
this.print(node.typeName, node, true);
|
||||
this.print(node.typeParameters, node, true);
|
||||
this.print(node.typeName, !!node.typeParameters);
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
function TSTypePredicate(node) {
|
||||
if (node.asserts) {
|
||||
@@ -292,51 +302,41 @@ function TSTypeQuery(node) {
|
||||
this.space();
|
||||
this.print(node.exprName);
|
||||
if (node.typeParameters) {
|
||||
this.print(node.typeParameters, node);
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
}
|
||||
function TSTypeLiteral(node) {
|
||||
this.tsPrintTypeLiteralOrInterfaceBody(node.members, node);
|
||||
}
|
||||
function tsPrintTypeLiteralOrInterfaceBody(members, node) {
|
||||
tsPrintBraced(this, members, node);
|
||||
}
|
||||
function tsPrintBraced(printer, members, node) {
|
||||
printer.token("{");
|
||||
if (members.length) {
|
||||
printer.indent();
|
||||
printer.newline();
|
||||
for (const member of members) {
|
||||
printer.print(member, node);
|
||||
printer.newline();
|
||||
}
|
||||
printer.dedent();
|
||||
}
|
||||
printer.rightBrace(node);
|
||||
printBraced(this, node, () => this.printJoin(node.members, {
|
||||
indent: true,
|
||||
statement: true
|
||||
}));
|
||||
}
|
||||
function TSArrayType(node) {
|
||||
this.print(node.elementType, node, true);
|
||||
this.token("[]");
|
||||
this.print(node.elementType, true);
|
||||
this.tokenChar(91);
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSTupleType(node) {
|
||||
this.tokenChar(91);
|
||||
this.printList(node.elementTypes, node);
|
||||
this.printList(node.elementTypes, {
|
||||
printTrailingSeparator: this.shouldPrintTrailingComma("]")
|
||||
});
|
||||
this.tokenChar(93);
|
||||
}
|
||||
function TSOptionalType(node) {
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(63);
|
||||
}
|
||||
function TSRestType(node) {
|
||||
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);
|
||||
}
|
||||
function TSUnionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "|");
|
||||
@@ -345,10 +345,16 @@ function TSIntersectionType(node) {
|
||||
tsPrintUnionOrIntersectionType(this, node, "&");
|
||||
}
|
||||
function tsPrintUnionOrIntersectionType(printer, node, sep) {
|
||||
printer.printJoin(node.types, node, {
|
||||
separator() {
|
||||
var _printer$tokenMap;
|
||||
let hasLeadingToken = 0;
|
||||
if ((_printer$tokenMap = printer.tokenMap) != null && _printer$tokenMap.startMatches(node, sep)) {
|
||||
hasLeadingToken = 1;
|
||||
printer.token(sep);
|
||||
}
|
||||
printer.printJoin(node.types, {
|
||||
separator(i) {
|
||||
this.space();
|
||||
this.token(sep);
|
||||
this.token(sep, null, i + hasLeadingToken);
|
||||
this.space();
|
||||
}
|
||||
});
|
||||
@@ -369,24 +375,23 @@ function TSConditionalType(node) {
|
||||
this.print(node.falseType);
|
||||
}
|
||||
function TSInferType(node) {
|
||||
this.token("infer");
|
||||
this.space();
|
||||
this.word("infer");
|
||||
this.print(node.typeParameter);
|
||||
}
|
||||
function TSParenthesizedType(node) {
|
||||
this.tokenChar(40);
|
||||
this.print(node.typeAnnotation, node);
|
||||
this.print(node.typeAnnotation);
|
||||
this.tokenChar(41);
|
||||
}
|
||||
function TSTypeOperator(node) {
|
||||
this.word(node.operator);
|
||||
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);
|
||||
}
|
||||
function TSMappedType(node) {
|
||||
@@ -394,10 +399,10 @@ function TSMappedType(node) {
|
||||
nameType,
|
||||
optional,
|
||||
readonly,
|
||||
typeParameter,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
this.tokenChar(123);
|
||||
const exit = this.enterDelimited();
|
||||
this.space();
|
||||
if (readonly) {
|
||||
tokenIfPlusMinus(this, readonly);
|
||||
@@ -405,16 +410,20 @@ function TSMappedType(node) {
|
||||
this.space();
|
||||
}
|
||||
this.tokenChar(91);
|
||||
this.word(typeParameter.name);
|
||||
{
|
||||
this.word(node.typeParameter.name);
|
||||
}
|
||||
this.space();
|
||||
this.word("in");
|
||||
this.space();
|
||||
this.print(typeParameter.constraint, typeParameter);
|
||||
{
|
||||
this.print(node.typeParameter.constraint);
|
||||
}
|
||||
if (nameType) {
|
||||
this.space();
|
||||
this.word("as");
|
||||
this.space();
|
||||
this.print(nameType, node);
|
||||
this.print(nameType);
|
||||
}
|
||||
this.tokenChar(93);
|
||||
if (optional) {
|
||||
@@ -424,9 +433,10 @@ function TSMappedType(node) {
|
||||
if (typeAnnotation) {
|
||||
this.tokenChar(58);
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
this.print(typeAnnotation);
|
||||
}
|
||||
this.space();
|
||||
exit();
|
||||
this.tokenChar(125);
|
||||
}
|
||||
function tokenIfPlusMinus(self, tok) {
|
||||
@@ -435,11 +445,11 @@ function tokenIfPlusMinus(self, tok) {
|
||||
}
|
||||
}
|
||||
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);
|
||||
function TSClassImplements(node) {
|
||||
this.print(node.expression);
|
||||
this.print(node.typeParameters);
|
||||
}
|
||||
function TSInterfaceDeclaration(node) {
|
||||
const {
|
||||
@@ -455,19 +465,22 @@ function TSInterfaceDeclaration(node) {
|
||||
}
|
||||
this.word("interface");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(typeParameters, node);
|
||||
this.print(id);
|
||||
this.print(typeParameters);
|
||||
if (extendz != null && extendz.length) {
|
||||
this.space();
|
||||
this.word("extends");
|
||||
this.space();
|
||||
this.printList(extendz, node);
|
||||
this.printList(extendz);
|
||||
}
|
||||
this.space();
|
||||
this.print(body, node);
|
||||
this.print(body);
|
||||
}
|
||||
function TSInterfaceBody(node) {
|
||||
this.tsPrintTypeLiteralOrInterfaceBody(node.body, node);
|
||||
printBraced(this, node, () => this.printJoin(node.body, {
|
||||
indent: true,
|
||||
statement: true
|
||||
}));
|
||||
}
|
||||
function TSTypeAliasDeclaration(node) {
|
||||
const {
|
||||
@@ -482,27 +495,25 @@ function TSTypeAliasDeclaration(node) {
|
||||
}
|
||||
this.word("type");
|
||||
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();
|
||||
}
|
||||
function TSTypeExpression(node) {
|
||||
var _expression$trailingC;
|
||||
const {
|
||||
type,
|
||||
expression,
|
||||
typeAnnotation
|
||||
} = node;
|
||||
const forceParens = !!((_expression$trailingC = expression.trailingComments) != null && _expression$trailingC.length);
|
||||
this.print(expression, node, true, undefined, forceParens);
|
||||
this.print(expression, true);
|
||||
this.space();
|
||||
this.word(type === "TSAsExpression" ? "as" : "satisfies");
|
||||
this.space();
|
||||
this.print(typeAnnotation, node);
|
||||
this.print(typeAnnotation);
|
||||
}
|
||||
function TSTypeAssertion(node) {
|
||||
const {
|
||||
@@ -510,14 +521,14 @@ function TSTypeAssertion(node) {
|
||||
expression
|
||||
} = 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);
|
||||
}
|
||||
function TSEnumDeclaration(node) {
|
||||
const {
|
||||
@@ -536,53 +547,62 @@ function TSEnumDeclaration(node) {
|
||||
}
|
||||
this.word("enum");
|
||||
this.space();
|
||||
this.print(id, node);
|
||||
this.print(id);
|
||||
this.space();
|
||||
tsPrintBraced(this, members, node);
|
||||
printBraced(this, node, () => {
|
||||
var _this$shouldPrintTrai;
|
||||
return this.printList(members, {
|
||||
indent: true,
|
||||
statement: true,
|
||||
printTrailingSeparator: (_this$shouldPrintTrai = this.shouldPrintTrailingComma("}")) != null ? _this$shouldPrintTrai : true
|
||||
});
|
||||
});
|
||||
}
|
||||
function TSEnumMember(node) {
|
||||
const {
|
||||
id,
|
||||
initializer
|
||||
} = node;
|
||||
this.print(id, node);
|
||||
this.print(id);
|
||||
if (initializer) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(initializer, node);
|
||||
this.print(initializer);
|
||||
}
|
||||
this.tokenChar(44);
|
||||
}
|
||||
function TSModuleDeclaration(node) {
|
||||
const {
|
||||
declare,
|
||||
id
|
||||
id,
|
||||
kind
|
||||
} = node;
|
||||
if (declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
if (!node.global) {
|
||||
this.word(id.type === "Identifier" ? "namespace" : "module");
|
||||
this.word(kind != null ? kind : id.type === "Identifier" ? "namespace" : "module");
|
||||
this.space();
|
||||
}
|
||||
this.print(id, node);
|
||||
this.print(id);
|
||||
if (!node.body) {
|
||||
this.tokenChar(59);
|
||||
this.semicolon();
|
||||
return;
|
||||
}
|
||||
let body = node.body;
|
||||
while (body.type === "TSModuleDeclaration") {
|
||||
this.tokenChar(46);
|
||||
this.print(body.id, body);
|
||||
this.print(body.id);
|
||||
body = body.body;
|
||||
}
|
||||
this.space();
|
||||
this.print(body, node);
|
||||
this.print(body);
|
||||
}
|
||||
function TSModuleBlock(node) {
|
||||
tsPrintBraced(this, node.body, node);
|
||||
printBraced(this, node, () => this.printSequence(node.body, {
|
||||
indent: true
|
||||
}));
|
||||
}
|
||||
function TSImportType(node) {
|
||||
const {
|
||||
@@ -592,14 +612,14 @@ function TSImportType(node) {
|
||||
} = node;
|
||||
this.word("import");
|
||||
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);
|
||||
}
|
||||
}
|
||||
function TSImportEqualsDeclaration(node) {
|
||||
@@ -614,20 +634,20 @@ function TSImportEqualsDeclaration(node) {
|
||||
}
|
||||
this.word("import");
|
||||
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);
|
||||
}
|
||||
function TSExportAssignment(node) {
|
||||
@@ -635,8 +655,8 @@ function TSExportAssignment(node) {
|
||||
this.space();
|
||||
this.tokenChar(61);
|
||||
this.space();
|
||||
this.print(node.expression, node);
|
||||
this.tokenChar(59);
|
||||
this.print(node.expression);
|
||||
this.semicolon();
|
||||
}
|
||||
function TSNamespaceExportDeclaration(node) {
|
||||
this.word("export");
|
||||
@@ -645,45 +665,53 @@ function TSNamespaceExportDeclaration(node) {
|
||||
this.space();
|
||||
this.word("namespace");
|
||||
this.space();
|
||||
this.print(node.id, node);
|
||||
this.print(node.id);
|
||||
this.semicolon();
|
||||
}
|
||||
function tsPrintSignatureDeclarationBase(node) {
|
||||
const {
|
||||
typeParameters
|
||||
} = node;
|
||||
const parameters = node.parameters;
|
||||
this.print(typeParameters, node);
|
||||
this.print(typeParameters);
|
||||
this.tokenChar(40);
|
||||
this._parameters(parameters, node);
|
||||
this.tokenChar(41);
|
||||
this._parameters(parameters, ")");
|
||||
const returnType = node.typeAnnotation;
|
||||
this.print(returnType, node);
|
||||
this.print(returnType);
|
||||
}
|
||||
function tsPrintClassMemberModifiers(node) {
|
||||
const isField = node.type === "ClassAccessorProperty" || node.type === "ClassProperty";
|
||||
if (isField && node.declare) {
|
||||
this.word("declare");
|
||||
this.space();
|
||||
}
|
||||
if (node.accessibility) {
|
||||
this.word(node.accessibility);
|
||||
this.space();
|
||||
}
|
||||
printModifiersList(this, node, [isField && node.declare && "declare", node.accessibility]);
|
||||
if (node.static) {
|
||||
this.word("static");
|
||||
this.space();
|
||||
}
|
||||
if (node.override) {
|
||||
this.word("override");
|
||||
this.space();
|
||||
printModifiersList(this, node, [node.override && "override", node.abstract && "abstract", isField && node.readonly && "readonly"]);
|
||||
}
|
||||
function printBraced(printer, node, cb) {
|
||||
printer.token("{");
|
||||
const exit = printer.enterDelimited();
|
||||
cb();
|
||||
exit();
|
||||
printer.rightBrace(node);
|
||||
}
|
||||
function printModifiersList(printer, node, modifiers) {
|
||||
var _printer$tokenMap2;
|
||||
const modifiersSet = new Set();
|
||||
for (const modifier of modifiers) {
|
||||
if (modifier) modifiersSet.add(modifier);
|
||||
}
|
||||
if (node.abstract) {
|
||||
this.word("abstract");
|
||||
this.space();
|
||||
}
|
||||
if (isField && node.readonly) {
|
||||
this.word("readonly");
|
||||
this.space();
|
||||
(_printer$tokenMap2 = printer.tokenMap) == null || _printer$tokenMap2.find(node, tok => {
|
||||
if (modifiersSet.has(tok.value)) {
|
||||
printer.token(tok.value);
|
||||
printer.space();
|
||||
modifiersSet.delete(tok.value);
|
||||
return modifiersSet.size === 0;
|
||||
}
|
||||
});
|
||||
for (const modifier of modifiersSet) {
|
||||
printer.word(modifier);
|
||||
printer.space();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
node_modules/@babel/generator/lib/generators/typescript.js.map
generated
vendored
2
node_modules/@babel/generator/lib/generators/typescript.js.map
generated
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user