Don't use isClassPrivateMethod because is isn't supported in <7.2.0 (#9121)
This commit is contained in:
parent
282129ea66
commit
b927fb2a7e
@ -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)) {
|
if (!hasFeature(file, FEATURES.privateMethods)) {
|
||||||
throw path.buildCodeFrameError("Class private methods are not enabled.");
|
throw path.buildCodeFrameError("Class private methods are not enabled.");
|
||||||
}
|
}
|
||||||
|
|||||||
@ -11,8 +11,8 @@ export function buildPrivateNamesMap(props) {
|
|||||||
privateNamesMap.set(name, {
|
privateNamesMap.set(name, {
|
||||||
id: prop.scope.generateUidIdentifier(name),
|
id: prop.scope.generateUidIdentifier(name),
|
||||||
static: !!prop.node.static,
|
static: !!prop.node.static,
|
||||||
method: prop.isClassPrivateMethod(),
|
method: prop.isMethod(),
|
||||||
methodId: prop.isClassPrivateMethod()
|
methodId: prop.isMethod()
|
||||||
? prop.scope.generateUidIdentifier(name)
|
? prop.scope.generateUidIdentifier(name)
|
||||||
: undefined,
|
: undefined,
|
||||||
});
|
});
|
||||||
@ -321,34 +321,37 @@ export function buildFieldsInitNodes(
|
|||||||
|
|
||||||
for (const prop of props) {
|
for (const prop of props) {
|
||||||
const isStatic = prop.node.static;
|
const isStatic = prop.node.static;
|
||||||
const isPrivateField = prop.isClassPrivateProperty();
|
const isInstance = !isStatic;
|
||||||
const isPrivateMethod = prop.isClassPrivateMethod();
|
const isPrivate = prop.isPrivate();
|
||||||
|
const isPublic = !isPrivate;
|
||||||
|
const isField = prop.isProperty();
|
||||||
|
const isMethod = !isField;
|
||||||
|
|
||||||
switch (true) {
|
switch (true) {
|
||||||
case isStatic && isPrivateField && loose:
|
case isStatic && isPrivate && isField && loose:
|
||||||
staticNodes.push(
|
staticNodes.push(
|
||||||
buildPrivateFieldInitLoose(t.cloneNode(ref), prop, privateNamesMap),
|
buildPrivateFieldInitLoose(t.cloneNode(ref), prop, privateNamesMap),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case isStatic && isPrivateField && !loose:
|
case isStatic && isPrivate && isField && !loose:
|
||||||
staticNodes.push(
|
staticNodes.push(
|
||||||
buildPrivateStaticFieldInitSpec(prop, privateNamesMap),
|
buildPrivateStaticFieldInitSpec(prop, privateNamesMap),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case isStatic && !isPrivateField && loose:
|
case isStatic && isPublic && isField && loose:
|
||||||
staticNodes.push(buildPublicFieldInitLoose(t.cloneNode(ref), prop));
|
staticNodes.push(buildPublicFieldInitLoose(t.cloneNode(ref), prop));
|
||||||
break;
|
break;
|
||||||
case isStatic && !isPrivateField && !loose:
|
case isStatic && isPublic && isField && !loose:
|
||||||
staticNodes.push(
|
staticNodes.push(
|
||||||
buildPublicFieldInitSpec(t.cloneNode(ref), prop, state),
|
buildPublicFieldInitSpec(t.cloneNode(ref), prop, state),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case !isStatic && isPrivateField && loose:
|
case isInstance && isPrivate && isField && loose:
|
||||||
instanceNodes.push(
|
instanceNodes.push(
|
||||||
buildPrivateFieldInitLoose(t.thisExpression(), prop, privateNamesMap),
|
buildPrivateFieldInitLoose(t.thisExpression(), prop, privateNamesMap),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case !isStatic && isPrivateField && !loose:
|
case isInstance && isPrivate && isField && !loose:
|
||||||
instanceNodes.push(
|
instanceNodes.push(
|
||||||
buildPrivateInstanceFieldInitSpec(
|
buildPrivateInstanceFieldInitSpec(
|
||||||
t.thisExpression(),
|
t.thisExpression(),
|
||||||
@ -357,7 +360,7 @@ export function buildFieldsInitNodes(
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case !isStatic && isPrivateMethod && loose:
|
case isInstance && isPrivate && isMethod && loose:
|
||||||
instanceNodes.push(
|
instanceNodes.push(
|
||||||
buildPrivateMethodInitLoose(
|
buildPrivateMethodInitLoose(
|
||||||
t.thisExpression(),
|
t.thisExpression(),
|
||||||
@ -369,7 +372,7 @@ export function buildFieldsInitNodes(
|
|||||||
buildPrivateInstanceMethodDeclaration(prop, privateNamesMap),
|
buildPrivateInstanceMethodDeclaration(prop, privateNamesMap),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case !isStatic && isPrivateMethod && !loose:
|
case isInstance && isPrivate && isMethod && !loose:
|
||||||
instanceNodes.push(
|
instanceNodes.push(
|
||||||
buildPrivateInstanceMethodInitSpec(
|
buildPrivateInstanceMethodInitSpec(
|
||||||
t.thisExpression(),
|
t.thisExpression(),
|
||||||
@ -381,10 +384,10 @@ export function buildFieldsInitNodes(
|
|||||||
buildPrivateInstanceMethodDeclaration(prop, privateNamesMap),
|
buildPrivateInstanceMethodDeclaration(prop, privateNamesMap),
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case !isStatic && !isPrivateField && loose:
|
case isInstance && isPublic && isField && loose:
|
||||||
instanceNodes.push(buildPublicFieldInitLoose(t.thisExpression(), prop));
|
instanceNodes.push(buildPublicFieldInitLoose(t.thisExpression(), prop));
|
||||||
break;
|
break;
|
||||||
case !isStatic && !isPrivateField && !loose:
|
case isInstance && isPublic && isField && !loose:
|
||||||
instanceNodes.push(
|
instanceNodes.push(
|
||||||
buildPublicFieldInitSpec(t.thisExpression(), prop, state),
|
buildPublicFieldInitSpec(t.thisExpression(), prop, state),
|
||||||
);
|
);
|
||||||
|
|||||||
@ -75,7 +75,7 @@ export function createClassFeaturePlugin({
|
|||||||
privateNames.add(name);
|
privateNames.add(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (path.isProperty() || path.isClassPrivateMethod()) {
|
if (path.isProperty() || path.isPrivate()) {
|
||||||
props.push(path);
|
props.push(path);
|
||||||
} else if (path.isClassMethod({ kind: "constructor" })) {
|
} else if (path.isClassMethod({ kind: "constructor" })) {
|
||||||
constructor = path;
|
constructor = path;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user