@babel/helper-create-class-features-plugin
Advanced tools
Comparing version 7.14.8 to 7.15.0
@@ -72,5 +72,5 @@ "use strict"; | ||
}).replace(); | ||
const properties = [prop("kind", _core.types.stringLiteral(isMethod ? node.kind : "field")), prop("decorators", takeDecorators(node)), prop("static", node.static && _core.types.booleanLiteral(true)), prop("key", getKey(node))].filter(Boolean); | ||
const properties = [prop("kind", _core.types.stringLiteral(_core.types.isClassMethod(node) ? node.kind : "field")), prop("decorators", takeDecorators(node)), prop("static", node.static && _core.types.booleanLiteral(true)), prop("key", getKey(node))].filter(Boolean); | ||
if (isMethod) { | ||
if (_core.types.isClassMethod(node)) { | ||
const id = node.computed ? null : node.key; | ||
@@ -85,3 +85,3 @@ | ||
}) || node)); | ||
} else if (node.value) { | ||
} else if (_core.types.isClassProperty(node) && node.value) { | ||
properties.push(method("value", _core.template.statements.ast`return ${node.value}`)); | ||
@@ -88,0 +88,0 @@ } else { |
@@ -96,3 +96,3 @@ "use strict"; | ||
if (path.isPrivateMethod != null && path.isPrivateMethod()) { | ||
if (path.isClassPrivateMethod != null && path.isClassPrivateMethod()) { | ||
if (!hasFeature(file, FEATURES.privateMethods)) { | ||
@@ -99,0 +99,0 @@ throw path.buildCodeFrameError("Class private methods are not enabled."); |
@@ -27,7 +27,3 @@ "use strict"; | ||
for (const prop of props) { | ||
const isPrivate = prop.isPrivate(); | ||
const isMethod = !prop.isProperty(); | ||
const isInstance = !prop.node.static; | ||
if (isPrivate) { | ||
if (prop.isPrivate()) { | ||
const { | ||
@@ -38,12 +34,14 @@ name | ||
id: prop.scope.generateUidIdentifier(name), | ||
static: !isInstance, | ||
method: isMethod | ||
static: prop.node.static, | ||
method: !prop.isProperty() | ||
}; | ||
if (prop.node.kind === "get") { | ||
update.getId = prop.scope.generateUidIdentifier(`get_${name}`); | ||
} else if (prop.node.kind === "set") { | ||
update.setId = prop.scope.generateUidIdentifier(`set_${name}`); | ||
} else if (prop.node.kind === "method") { | ||
update.methodId = prop.scope.generateUidIdentifier(name); | ||
if (prop.isClassPrivateMethod()) { | ||
if (prop.node.kind === "get") { | ||
update.getId = prop.scope.generateUidIdentifier(`get_${name}`); | ||
} else if (prop.node.kind === "set") { | ||
update.setId = prop.scope.generateUidIdentifier(`set_${name}`); | ||
} else if (prop.node.kind === "method") { | ||
update.methodId = prop.scope.generateUidIdentifier(name); | ||
} | ||
} | ||
@@ -166,3 +164,3 @@ | ||
if (operator !== "in") return; | ||
if (!path.get("left").isPrivateName()) return; | ||
if (!_core.types.isPrivateName(left)) return; | ||
const { | ||
@@ -371,2 +369,6 @@ privateFieldsAsProperties, | ||
set() { | ||
throw new Error("private name handler with loose = true don't need set()"); | ||
}, | ||
boundGet(member) { | ||
@@ -722,3 +724,3 @@ return _core.types.callExpression(_core.types.memberExpression(this.get(member), _core.types.identifier("bind")), [_core.types.cloneNode(member.node.object)]); | ||
for (const prop of props) { | ||
ts.assertFieldTransformed(prop); | ||
prop.isClassProperty() && ts.assertFieldTransformed(prop); | ||
const isStatic = prop.node.static; | ||
@@ -725,0 +727,0 @@ const isInstance = !isStatic; |
@@ -40,3 +40,3 @@ "use strict"; | ||
const version = "7.14.8".split(".").reduce((v, x) => v * 1e5 + +x, 0); | ||
const version = "7.15.0".split(".").reduce((v, x) => v * 1e5 + +x, 0); | ||
const versionKey = "@babel/plugin-class-features/version"; | ||
@@ -50,3 +50,3 @@ | ||
api = { | ||
assumption: () => {} | ||
assumption: () => void 0 | ||
} | ||
@@ -93,3 +93,3 @@ }) { | ||
let constructor; | ||
let isDecorated = (0, _decorators.hasOwnDecorators)(path.node); | ||
const isDecorated = (0, _decorators.hasDecorators)(path.node); | ||
const props = []; | ||
@@ -104,3 +104,3 @@ const elements = []; | ||
if (path.node.computed) { | ||
if ((path.isClassProperty() || path.isClassMethod()) && path.node.computed) { | ||
computedPaths.push(path); | ||
@@ -116,14 +116,16 @@ } | ||
if (path.node.kind === "get") { | ||
if (privateNames.has(getName) || privateNames.has(name) && !privateNames.has(setName)) { | ||
throw path.buildCodeFrameError("Duplicate private field"); | ||
} | ||
if (path.isClassPrivateMethod()) { | ||
if (path.node.kind === "get") { | ||
if (privateNames.has(getName) || privateNames.has(name) && !privateNames.has(setName)) { | ||
throw path.buildCodeFrameError("Duplicate private field"); | ||
} | ||
privateNames.add(getName).add(name); | ||
} else if (path.node.kind === "set") { | ||
if (privateNames.has(setName) || privateNames.has(name) && !privateNames.has(getName)) { | ||
throw path.buildCodeFrameError("Duplicate private field"); | ||
privateNames.add(getName).add(name); | ||
} else if (path.node.kind === "set") { | ||
if (privateNames.has(setName) || privateNames.has(name) && !privateNames.has(getName)) { | ||
throw path.buildCodeFrameError("Duplicate private field"); | ||
} | ||
privateNames.add(setName).add(name); | ||
} | ||
privateNames.add(setName).add(name); | ||
} else { | ||
@@ -149,4 +151,2 @@ if (privateNames.has(name) && !privateNames.has(getName) && !privateNames.has(setName) || privateNames.has(name) && (privateNames.has(getName) || privateNames.has(setName))) { | ||
} | ||
if (!isDecorated) isDecorated = (0, _decorators.hasOwnDecorators)(path.node); | ||
} | ||
@@ -171,3 +171,3 @@ | ||
}, state); | ||
let keysNodes, staticNodes, pureStaticNodes, instanceNodes, wrapClass; | ||
let keysNodes, staticNodes, instanceNodes, pureStaticNodes, wrapClass; | ||
@@ -201,11 +201,11 @@ if (isDecorated) { | ||
path = wrapClass(path); | ||
path.insertBefore([...privateNamesNodes, ...keysNodes]); | ||
const wrappedPath = wrapClass(path); | ||
wrappedPath.insertBefore([...privateNamesNodes, ...keysNodes]); | ||
if (staticNodes.length > 0) { | ||
path.insertAfter(staticNodes); | ||
wrappedPath.insertAfter(staticNodes); | ||
} | ||
if (pureStaticNodes.length > 0) { | ||
path.find(parent => parent.isStatement() || parent.isDeclaration()).insertAfter(pureStaticNodes); | ||
wrappedPath.find(parent => parent.isStatement() || parent.isDeclaration()).insertAfter(pureStaticNodes); | ||
} | ||
@@ -212,0 +212,0 @@ }, |
{ | ||
"name": "@babel/helper-create-class-features-plugin", | ||
"version": "7.14.8", | ||
"version": "7.15.0", | ||
"author": "The Babel Team (https://babel.dev/team)", | ||
@@ -23,5 +23,5 @@ "license": "MIT", | ||
"@babel/helper-function-name": "^7.14.5", | ||
"@babel/helper-member-expression-to-functions": "^7.14.7", | ||
"@babel/helper-member-expression-to-functions": "^7.15.0", | ||
"@babel/helper-optimise-call-expression": "^7.14.5", | ||
"@babel/helper-replace-supers": "^7.14.5", | ||
"@babel/helper-replace-supers": "^7.15.0", | ||
"@babel/helper-split-export-declaration": "^7.14.5" | ||
@@ -33,5 +33,5 @@ }, | ||
"devDependencies": { | ||
"@babel/core": "7.14.8", | ||
"@babel/core": "7.15.0", | ||
"@babel/helper-plugin-test-runner": "7.14.5", | ||
"@babel/preset-env": "7.14.8" | ||
"@babel/preset-env": "7.15.0" | ||
}, | ||
@@ -38,0 +38,0 @@ "engines": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
49689
1242