@babel/plugin-transform-typescript
Advanced tools
Comparing version 7.17.12 to 7.18.0
@@ -125,28 +125,32 @@ "use strict"; | ||
if (path.node.accessibility) path.node.accessibility = null; | ||
const parameterProperties = []; | ||
const assigns = []; | ||
const { | ||
scope | ||
} = path; | ||
for (const param of path.node.params) { | ||
if (param.type === "TSParameterProperty" && !PARSED_PARAMS.has(param.parameter)) { | ||
PARSED_PARAMS.add(param.parameter); | ||
parameterProperties.push(param.parameter); | ||
} | ||
} | ||
for (const paramPath of path.get("params")) { | ||
const param = paramPath.node; | ||
if (parameterProperties.length) { | ||
const assigns = parameterProperties.map(p => { | ||
if (param.type === "TSParameterProperty") { | ||
const parameter = param.parameter; | ||
if (PARSED_PARAMS.has(parameter)) continue; | ||
PARSED_PARAMS.add(parameter); | ||
let id; | ||
if (_core.types.isIdentifier(p)) { | ||
id = p; | ||
} else if (_core.types.isAssignmentPattern(p) && _core.types.isIdentifier(p.left)) { | ||
id = p.left; | ||
if (_core.types.isIdentifier(parameter)) { | ||
id = parameter; | ||
} else if (_core.types.isAssignmentPattern(parameter) && _core.types.isIdentifier(parameter.left)) { | ||
id = parameter.left; | ||
} else { | ||
throw path.buildCodeFrameError("Parameter properties can not be destructuring patterns."); | ||
throw paramPath.buildCodeFrameError("Parameter properties can not be destructuring patterns."); | ||
} | ||
return _core.template.statement.ast` | ||
this.${_core.types.cloneNode(id)} = ${_core.types.cloneNode(id)}`; | ||
}); | ||
(0, _helperCreateClassFeaturesPlugin.injectInitialization)(classPath, path, assigns); | ||
assigns.push(_core.template.statement.ast` | ||
this.${_core.types.cloneNode(id)} = ${_core.types.cloneNode(id)}`); | ||
paramPath.replaceWith(paramPath.get("parameter")); | ||
scope.registerBinding("param", paramPath); | ||
} | ||
} | ||
(0, _helperCreateClassFeaturesPlugin.injectInitialization)(classPath, path, assigns); | ||
} | ||
@@ -401,4 +405,3 @@ | ||
const { | ||
node, | ||
scope | ||
node | ||
} = path; | ||
@@ -414,11 +417,2 @@ if (node.typeParameters) node.typeParameters = null; | ||
} | ||
const paramsPath = path.get("params"); | ||
for (const p of paramsPath) { | ||
if (p.type === "TSParameterProperty") { | ||
p.replaceWith(p.get("parameter")); | ||
scope.registerBinding("param", p); | ||
} | ||
} | ||
}, | ||
@@ -474,3 +468,3 @@ | ||
TSNonNullExpression(path) { | ||
"TSNonNullExpression|TSInstantiationExpression"(path) { | ||
path.replaceWith(path.node.expression); | ||
@@ -477,0 +471,0 @@ }, |
{ | ||
"name": "@babel/plugin-transform-typescript", | ||
"version": "7.17.12", | ||
"version": "7.18.0", | ||
"description": "Transform TypeScript into ES.next", | ||
@@ -20,3 +20,3 @@ "repository": { | ||
"dependencies": { | ||
"@babel/helper-create-class-features-plugin": "^7.17.12", | ||
"@babel/helper-create-class-features-plugin": "^7.18.0", | ||
"@babel/helper-plugin-utils": "^7.17.12", | ||
@@ -29,6 +29,6 @@ "@babel/plugin-syntax-typescript": "^7.17.12" | ||
"devDependencies": { | ||
"@babel/core": "^7.17.12", | ||
"@babel/core": "^7.18.0", | ||
"@babel/helper-plugin-test-runner": "^7.16.7", | ||
"@babel/traverse": "^7.17.12", | ||
"@babel/types": "^7.17.12" | ||
"@babel/traverse": "^7.18.0", | ||
"@babel/types": "^7.18.0" | ||
}, | ||
@@ -35,0 +35,0 @@ "homepage": "https://babel.dev/docs/en/next/babel-plugin-transform-typescript", |
32845
858
+ Addedcaniuse-lite@1.0.30001618(transitive)
+ Addedpicocolors@1.0.1(transitive)
+ Addedupdate-browserslist-db@1.0.16(transitive)
- Removedcaniuse-lite@1.0.30001616(transitive)
- Removedelectron-to-chromium@1.4.763(transitive)
- Removedpicocolors@1.0.0(transitive)
- Removedupdate-browserslist-db@1.0.15(transitive)