@babel/plugin-transform-typescript
Advanced tools
Comparing version 7.20.7 to 7.20.13
@@ -29,3 +29,2 @@ "use strict"; | ||
const entriesMap = new Map(entries); | ||
path.scope.path.traverse({ | ||
@@ -32,0 +31,0 @@ Scope(path) { |
@@ -64,3 +64,2 @@ "use strict"; | ||
const buildEnumMember = (isString, options) => (isString ? buildStringAssignment : buildNumericAssignment)(options); | ||
function enumFill(path, t, id) { | ||
@@ -78,3 +77,2 @@ const x = translateEnumValues(path, t); | ||
} | ||
function ReferencedIdentifier(expr, state) { | ||
@@ -147,3 +145,2 @@ const { | ||
} | ||
function evaluate(expr, seen) { | ||
@@ -150,0 +147,0 @@ return evalConstant(expr); |
@@ -20,9 +20,5 @@ "use strict"; | ||
case "TSQualifiedName": | ||
return ( | ||
path.parentPath.findParent(path => path.type !== "TSQualifiedName").type !== "TSImportEqualsDeclaration" | ||
); | ||
return path.parentPath.findParent(path => path.type !== "TSQualifiedName").type !== "TSImportEqualsDeclaration"; | ||
case "ExportSpecifier": | ||
return ( | ||
path.parentPath.parent.exportKind === "type" | ||
); | ||
return path.parentPath.parent.exportKind === "type"; | ||
default: | ||
@@ -46,3 +42,2 @@ return false; | ||
} | ||
function safeRemove(path) { | ||
@@ -105,2 +100,4 @@ const ids = path.getBindingIdentifiers(); | ||
} | ||
} else if (node.abstract) { | ||
path.remove(); | ||
} else { | ||
@@ -127,5 +124,3 @@ if (!allowDeclareFields && !node.value && !node.decorators && !t.isClassPrivateProperty(node)) { | ||
if (node.override) node.override = null; | ||
}, | ||
constructor(path, classPath) { | ||
@@ -198,3 +193,2 @@ if (path.node.accessibility) path.node.accessibility = null; | ||
} | ||
for (let stmt of path.get("body")) { | ||
@@ -224,3 +218,2 @@ if (stmt.isImportDeclaration()) { | ||
} | ||
if (onlyRemoveTypeImports) { | ||
@@ -235,3 +228,2 @@ NEEDS_EXPLICIT_ESM.set(path.node, false); | ||
const binding = stmt.scope.getBinding(specifier.local.name); | ||
if (binding && !importsToRemove.has(binding.path)) { | ||
@@ -251,3 +243,3 @@ if (isImportTypeOnly({ | ||
} | ||
if (isAllSpecifiersElided()) { | ||
if (isAllSpecifiersElided() && !onlyRemoveTypeImports) { | ||
stmt.remove(); | ||
@@ -295,3 +287,2 @@ } else { | ||
} | ||
if (path.node.source && path.node.specifiers.length > 0 && path.node.specifiers.every(specifier => specifier.type === "ExportSpecifier" && specifier.exportKind === "type")) { | ||
@@ -301,3 +292,2 @@ path.remove(); | ||
} | ||
if (!path.node.source && path.node.specifiers.length > 0 && path.node.specifiers.every(specifier => t.isExportSpecifier(specifier) && isGlobalType(path, specifier.local.name))) { | ||
@@ -310,3 +300,2 @@ path.remove(); | ||
ExportSpecifier(path) { | ||
const parent = path.parent; | ||
@@ -321,3 +310,2 @@ if (!parent.source && isGlobalType(path, path.node.local.name) || path.node.exportKind === "type") { | ||
} | ||
if (t.isIdentifier(path.node.declaration) && isGlobalType(path, path.node.declaration.name)) { | ||
@@ -364,8 +352,6 @@ path.remove(); | ||
if (node.abstract) node.abstract = null; | ||
path.get("body.body").forEach(child => { | ||
if (child.isClassMethod() || child.isClassPrivateMethod()) { | ||
if (child.node.kind === "constructor") { | ||
classMemberVisitors.constructor( | ||
child, path); | ||
classMemberVisitors.constructor(child, path); | ||
} else { | ||
@@ -412,3 +398,2 @@ classMemberVisitors.method(child); | ||
} | ||
path.replaceWith(t.variableDeclaration("var", [t.variableDeclarator(path.node.id, entityNameToExpr(path.node.moduleReference))])); | ||
@@ -422,4 +407,3 @@ }, | ||
}, | ||
[`TSAsExpression${ | ||
t.tsSatisfiesExpression ? "|TSSatisfiesExpression" : ""}`](path) { | ||
[`TSAsExpression${t.tsSatisfiesExpression ? "|TSSatisfiesExpression" : ""}`](path) { | ||
let { | ||
@@ -433,4 +417,3 @@ node | ||
}, | ||
[ | ||
api.types.tsInstantiationExpression ? "TSNonNullExpression|TSInstantiationExpression" : "TSNonNullExpression"](path) { | ||
[api.types.tsInstantiationExpression ? "TSNonNullExpression|TSInstantiationExpression" : "TSNonNullExpression"](path) { | ||
path.replaceWith(path.node.expression); | ||
@@ -467,3 +450,2 @@ }, | ||
} | ||
function isImportTypeOnly({ | ||
@@ -483,3 +465,2 @@ binding, | ||
} | ||
let sourceFileHasJsx = false; | ||
@@ -486,0 +467,0 @@ programPath.traverse({ |
@@ -39,3 +39,2 @@ "use strict"; | ||
} | ||
function handleVariableDeclaration(node, name, hub) { | ||
@@ -69,7 +68,5 @@ if (node.kind !== "const") { | ||
const name = path.scope.generateUid(realName.name); | ||
const namespaceTopLevel = _core.types.isTSModuleBlock(node.body) ? node.body.body : | ||
[_core.types.exportNamedDeclaration(node.body)]; | ||
const namespaceTopLevel = _core.types.isTSModuleBlock(node.body) ? node.body.body : [_core.types.exportNamedDeclaration(node.body)]; | ||
for (let i = 0; i < namespaceTopLevel.length; i++) { | ||
const subNode = namespaceTopLevel[i]; | ||
switch (subNode.type) { | ||
@@ -107,7 +104,5 @@ case "TSModuleDeclaration": | ||
} | ||
if ("declare" in subNode.declaration && subNode.declaration.declare) { | ||
continue; | ||
} | ||
switch (subNode.declaration.type) { | ||
@@ -146,3 +141,2 @@ case "TSEnumDeclaration": | ||
} | ||
let fallthroughValue = _core.types.objectExpression([]); | ||
@@ -149,0 +143,0 @@ if (parentExport) { |
{ | ||
"name": "@babel/plugin-transform-typescript", | ||
"version": "7.20.7", | ||
"version": "7.20.13", | ||
"description": "Transform TypeScript into ES.next", | ||
@@ -20,3 +20,3 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-create-class-features-plugin": "^7.20.7", | ||
"@babel/helper-create-class-features-plugin": "^7.20.12", | ||
"@babel/helper-plugin-utils": "^7.20.2", | ||
@@ -29,5 +29,5 @@ "@babel/plugin-syntax-typescript": "^7.20.0" | ||
"devDependencies": { | ||
"@babel/core": "^7.20.7", | ||
"@babel/core": "^7.20.12", | ||
"@babel/helper-plugin-test-runner": "^7.18.6", | ||
"@babel/traverse": "^7.20.7", | ||
"@babel/traverse": "^7.20.13", | ||
"@babel/types": "^7.20.7" | ||
@@ -34,0 +34,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
113465
131
3
7
2
25
887