Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: PrivateName Identifier should not be isReferenced. #9861

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -3,7 +3,7 @@ var Point =
function () {
"use strict";

function Point(_x2 = 0, _y2 = 0) {
function Point(x = 0, y = 0) {
babelHelpers.classCallCheck(this, Point);
Object.defineProperty(this, _x, {
writable: true,
Expand All @@ -13,8 +13,8 @@ function () {
writable: true,
value: void 0
});
babelHelpers.classPrivateFieldLooseBase(this, _x)[_x] = +_x2;
babelHelpers.classPrivateFieldLooseBase(this, _y)[_y] = +_y2;
babelHelpers.classPrivateFieldLooseBase(this, _x)[_x] = +x;
babelHelpers.classPrivateFieldLooseBase(this, _y)[_y] = +y;
}

babelHelpers.createClass(Point, [{
Expand Down
Expand Up @@ -3,7 +3,7 @@ var Point =
function () {
"use strict";

function Point(_x2 = 0, _y2 = 0) {
function Point(x = 0, y = 0) {
babelHelpers.classCallCheck(this, Point);

_x.set(this, {
Expand All @@ -16,8 +16,8 @@ function () {
value: void 0
});

babelHelpers.classPrivateFieldSet(this, _x, +_x2);
babelHelpers.classPrivateFieldSet(this, _y, +_y2);
babelHelpers.classPrivateFieldSet(this, _x, +x);
babelHelpers.classPrivateFieldSet(this, _y, +y);
}

babelHelpers.createClass(Point, [{
Expand Down
@@ -0,0 +1,14 @@
import {test1, test2, test3, test4, test5, test6, test7, test8, test9} from 'anywhere';

class Example {
#test1 = test1;
test2 = test2;
#test3() { return test3; }
test4() { return test4; }
get #test5() { return test5; }
get test6() { return test6; }

#test7 = this.#test1;
#test8() { return this.#test3(); }
get #test9() { return this.#test5(); }
}
@@ -0,0 +1,35 @@
"use strict";

var _anywhere = require("anywhere");

class Example {
#test1 = _anywhere.test1;
test2 = _anywhere.test2;

#test3() {
return _anywhere.test3;
}

test4() {
return _anywhere.test4;
}

get #test5() {
return _anywhere.test5;
}

get test6() {
return _anywhere.test6;
}

#test7 = this.#test1;

#test8() {
return this.#test3();
}

get #test9() {
return this.#test5();
}

}
7 changes: 7 additions & 0 deletions packages/babel-types/src/validators/isReferenced.js
Expand Up @@ -38,6 +38,13 @@ export default function isReferenced(
}
return parent.local === node;

// no: class { #NODE; }
// no: class { get #NODE() {} }
// no: class { #NODE() {} }
// no: class { fn() { return this.#NODE; } }
case "PrivateName":
return false;

// yes: { [NODE]: "" }
// no: { NODE: "" }
// depends: { NODE }
Expand Down