Evaluate object and initializer when setting a private method (#12707)
* fix: evaluate initializer when a private method is set as a field * make legacy node happy * add accessor test cases * fix: evaluate object before RHS * fix: evaluate object before throwing writeOnlyError
This commit is contained in:
@@ -232,8 +232,11 @@ const privateNameHandlerSpec = {
|
||||
if (isAccessor) {
|
||||
if (!getId && setId) {
|
||||
if (file.availableHelper("writeOnlyError")) {
|
||||
return t.callExpression(file.addHelper("writeOnlyError"), [
|
||||
t.stringLiteral(`#${name}`),
|
||||
return t.sequenceExpression([
|
||||
this.receiver(member),
|
||||
t.callExpression(file.addHelper("writeOnlyError"), [
|
||||
t.stringLiteral(`#${name}`),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
console.warn(
|
||||
@@ -299,8 +302,12 @@ const privateNameHandlerSpec = {
|
||||
value,
|
||||
]);
|
||||
}
|
||||
return t.callExpression(file.addHelper("readOnlyError"), [
|
||||
t.stringLiteral(`#${name}`),
|
||||
return t.sequenceExpression([
|
||||
this.receiver(member),
|
||||
value,
|
||||
t.callExpression(file.addHelper("readOnlyError"), [
|
||||
t.stringLiteral(`#${name}`),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
return t.callExpression(file.addHelper("classPrivateFieldSet"), [
|
||||
|
||||
Reference in New Issue
Block a user