@babel/plugin-transform-typescript
Advanced tools
Comparing version 7.14.6 to 7.15.0
@@ -7,2 +7,3 @@ "use strict"; | ||
exports.default = transpileEnum; | ||
exports.translateEnumValues = translateEnumValues; | ||
@@ -18,6 +19,2 @@ var _assert = require("assert"); | ||
if (node.const) { | ||
throw path.buildCodeFrameError("'const' enums are not supported."); | ||
} | ||
if (node.declare) { | ||
@@ -24,0 +21,0 @@ path.remove(); |
@@ -16,2 +16,4 @@ "use strict"; | ||
var _constEnum = require("./const-enum"); | ||
var _enum = require("./enum"); | ||
@@ -60,3 +62,4 @@ | ||
jsxPragmaFrag = "React.Fragment", | ||
onlyRemoveTypeImports = false | ||
onlyRemoveTypeImports = false, | ||
optimizeConstEnums = false | ||
} = opts; | ||
@@ -258,3 +261,3 @@ { | ||
} | ||
} else if (stmt.isTSTypeAliasDeclaration() || stmt.isTSDeclareFunction() || stmt.isTSInterfaceDeclaration() || stmt.isClassDeclaration({ | ||
} else if (stmt.isTSTypeAliasDeclaration() || stmt.isTSDeclareFunction() && stmt.get("id").isIdentifier() || stmt.isTSInterfaceDeclaration() || stmt.isClassDeclaration({ | ||
declare: true | ||
@@ -412,7 +415,15 @@ }) || stmt.isTSEnumDeclaration({ | ||
TSEnumDeclaration(path) { | ||
(0, _enum.default)(path, _core.types); | ||
if (optimizeConstEnums && path.node.const) { | ||
(0, _constEnum.default)(path, _core.types); | ||
} else { | ||
(0, _enum.default)(path, _core.types); | ||
} | ||
}, | ||
TSImportEqualsDeclaration(path) { | ||
throw path.buildCodeFrameError("`import =` is not supported by @babel/plugin-transform-typescript\n" + "Please consider using " + "`import <moduleName> from '<moduleName>';` alongside " + "Typescript's --allowSyntheticDefaultImports option."); | ||
if (_core.types.isTSExternalModuleReference(path.node.moduleReference)) { | ||
throw path.buildCodeFrameError(`\`import ${path.node.id.name} = require('${path.node.moduleReference.expression.value}')\` ` + "is not supported by @babel/plugin-transform-typescript\n" + "Please consider using " + `\`import ${path.node.id.name} from '${path.node.moduleReference.expression.value}';\` alongside ` + "Typescript's --allowSyntheticDefaultImports option."); | ||
} | ||
path.replaceWith(_core.types.variableDeclaration("var", [_core.types.variableDeclarator(path.node.id, entityNameToExpr(path.node.moduleReference))])); | ||
}, | ||
@@ -467,2 +478,10 @@ | ||
function entityNameToExpr(node) { | ||
if (_core.types.isTSQualifiedName(node)) { | ||
return _core.types.memberExpression(entityNameToExpr(node.left), node.right); | ||
} | ||
return node; | ||
} | ||
function visitPattern({ | ||
@@ -469,0 +488,0 @@ node |
{ | ||
"name": "@babel/plugin-transform-typescript", | ||
"version": "7.14.6", | ||
"version": "7.15.0", | ||
"description": "Transform TypeScript into ES.next", | ||
@@ -20,3 +20,3 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-create-class-features-plugin": "^7.14.6", | ||
"@babel/helper-create-class-features-plugin": "^7.15.0", | ||
"@babel/helper-plugin-utils": "^7.14.5", | ||
@@ -29,6 +29,6 @@ "@babel/plugin-syntax-typescript": "^7.14.5" | ||
"devDependencies": { | ||
"@babel/core": "7.14.6", | ||
"@babel/core": "7.15.0", | ||
"@babel/helper-plugin-test-runner": "7.14.5", | ||
"@babel/traverse": "7.14.5", | ||
"@babel/types": "7.14.5" | ||
"@babel/traverse": "7.15.0", | ||
"@babel/types": "7.15.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-typescript", |
30173
7
803