Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8b132c0889 | ||
|
|
b927fb2a7e |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"lerna": "2.11.0",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.1",
|
||||
"changelog": {
|
||||
"repo": "babel/babel",
|
||||
"cacheDir": ".changelog",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/helper-create-class-features-plugin",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.1",
|
||||
"author": "The Babel Team (https://babeljs.io/team)",
|
||||
"license": "MIT",
|
||||
"description": "Compile class public and private fields, private methods and decorators to ES6",
|
||||
|
||||
@@ -49,7 +49,8 @@ export function verifyUsedFeatures(path, file) {
|
||||
);
|
||||
}
|
||||
|
||||
if (path.isClassPrivateMethod()) {
|
||||
// NOTE: We can't use path.isPrivateMethod() because it isn't supported in <7.2.0
|
||||
if (path.isPrivate() && path.isMethod()) {
|
||||
if (!hasFeature(file, FEATURES.privateMethods)) {
|
||||
throw path.buildCodeFrameError("Class private methods are not enabled.");
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ export function buildPrivateNamesMap(props) {
|
||||
privateNamesMap.set(name, {
|
||||
id: prop.scope.generateUidIdentifier(name),
|
||||
static: !!prop.node.static,
|
||||
method: prop.isClassPrivateMethod(),
|
||||
methodId: prop.isClassPrivateMethod()
|
||||
method: prop.isMethod(),
|
||||
methodId: prop.isMethod()
|
||||
? prop.scope.generateUidIdentifier(name)
|
||||
: undefined,
|
||||
});
|
||||
@@ -321,34 +321,37 @@ export function buildFieldsInitNodes(
|
||||
|
||||
for (const prop of props) {
|
||||
const isStatic = prop.node.static;
|
||||
const isPrivateField = prop.isClassPrivateProperty();
|
||||
const isPrivateMethod = prop.isClassPrivateMethod();
|
||||
const isInstance = !isStatic;
|
||||
const isPrivate = prop.isPrivate();
|
||||
const isPublic = !isPrivate;
|
||||
const isField = prop.isProperty();
|
||||
const isMethod = !isField;
|
||||
|
||||
switch (true) {
|
||||
case isStatic && isPrivateField && loose:
|
||||
case isStatic && isPrivate && isField && loose:
|
||||
staticNodes.push(
|
||||
buildPrivateFieldInitLoose(t.cloneNode(ref), prop, privateNamesMap),
|
||||
);
|
||||
break;
|
||||
case isStatic && isPrivateField && !loose:
|
||||
case isStatic && isPrivate && isField && !loose:
|
||||
staticNodes.push(
|
||||
buildPrivateStaticFieldInitSpec(prop, privateNamesMap),
|
||||
);
|
||||
break;
|
||||
case isStatic && !isPrivateField && loose:
|
||||
case isStatic && isPublic && isField && loose:
|
||||
staticNodes.push(buildPublicFieldInitLoose(t.cloneNode(ref), prop));
|
||||
break;
|
||||
case isStatic && !isPrivateField && !loose:
|
||||
case isStatic && isPublic && isField && !loose:
|
||||
staticNodes.push(
|
||||
buildPublicFieldInitSpec(t.cloneNode(ref), prop, state),
|
||||
);
|
||||
break;
|
||||
case !isStatic && isPrivateField && loose:
|
||||
case isInstance && isPrivate && isField && loose:
|
||||
instanceNodes.push(
|
||||
buildPrivateFieldInitLoose(t.thisExpression(), prop, privateNamesMap),
|
||||
);
|
||||
break;
|
||||
case !isStatic && isPrivateField && !loose:
|
||||
case isInstance && isPrivate && isField && !loose:
|
||||
instanceNodes.push(
|
||||
buildPrivateInstanceFieldInitSpec(
|
||||
t.thisExpression(),
|
||||
@@ -357,7 +360,7 @@ export function buildFieldsInitNodes(
|
||||
),
|
||||
);
|
||||
break;
|
||||
case !isStatic && isPrivateMethod && loose:
|
||||
case isInstance && isPrivate && isMethod && loose:
|
||||
instanceNodes.push(
|
||||
buildPrivateMethodInitLoose(
|
||||
t.thisExpression(),
|
||||
@@ -369,7 +372,7 @@ export function buildFieldsInitNodes(
|
||||
buildPrivateInstanceMethodDeclaration(prop, privateNamesMap),
|
||||
);
|
||||
break;
|
||||
case !isStatic && isPrivateMethod && !loose:
|
||||
case isInstance && isPrivate && isMethod && !loose:
|
||||
instanceNodes.push(
|
||||
buildPrivateInstanceMethodInitSpec(
|
||||
t.thisExpression(),
|
||||
@@ -381,10 +384,10 @@ export function buildFieldsInitNodes(
|
||||
buildPrivateInstanceMethodDeclaration(prop, privateNamesMap),
|
||||
);
|
||||
break;
|
||||
case !isStatic && !isPrivateField && loose:
|
||||
case isInstance && isPublic && isField && loose:
|
||||
instanceNodes.push(buildPublicFieldInitLoose(t.thisExpression(), prop));
|
||||
break;
|
||||
case !isStatic && !isPrivateField && !loose:
|
||||
case isInstance && isPublic && isField && !loose:
|
||||
instanceNodes.push(
|
||||
buildPublicFieldInitSpec(t.thisExpression(), prop, state),
|
||||
);
|
||||
|
||||
@@ -75,7 +75,7 @@ export function createClassFeaturePlugin({
|
||||
privateNames.add(name);
|
||||
}
|
||||
|
||||
if (path.isProperty() || path.isClassPrivateMethod()) {
|
||||
if (path.isProperty() || path.isPrivate()) {
|
||||
props.push(path);
|
||||
} else if (path.isClassMethod({ kind: "constructor" })) {
|
||||
constructor = path;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-proposal-class-properties",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.1",
|
||||
"description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-class-properties",
|
||||
"license": "MIT",
|
||||
@@ -12,7 +12,7 @@
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-create-class-features-plugin": "^7.2.0",
|
||||
"@babel/helper-create-class-features-plugin": "^7.2.1",
|
||||
"@babel/helper-plugin-utils": "^7.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@babel/plugin-proposal-private-methods",
|
||||
"version": "7.2.0",
|
||||
"version": "7.2.1",
|
||||
"description": "This plugin transforms private class methods",
|
||||
"repository": "https://github.com/babel/babel/tree/master/packages/babel-plugin-proposal-private-methods",
|
||||
"license": "MIT",
|
||||
@@ -12,7 +12,7 @@
|
||||
"babel-plugin"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/helper-create-class-features-plugin": "^7.2.0",
|
||||
"@babel/helper-create-class-features-plugin": "^7.2.1",
|
||||
"@babel/helper-plugin-utils": "^7.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
|
||||
Reference in New Issue
Block a user