Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ES private class elements#42458

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from1 commit
Commits
Show all changes
87 commits
Select commitHold shift + click to select a range
e3a3fb8
Added support for private identifier methods.
dragomirtitianJan 15, 2021
4ab27a2
Added tests for private methods.
dragomirtitianJan 15, 2021
6977b9f
Added check to only not allow private name method signatures in anyth…
dragomirtitianJan 18, 2021
bc8c07e
Added private accessors tests
dragomirtitianJan 19, 2021
2760ed8
Transform private methods
mkubilaykJan 25, 2021
04af85d
Rename shouldTransformPrivateFields
mkubilaykJan 25, 2021
f048d72
Accept baseline
mkubilaykJan 25, 2021
f8cfb81
Use a single WeakSet for brand-check
mkubilaykJan 26, 2021
4aa4c3b
Accept baseline
mkubilaykJan 26, 2021
0ac1271
Add a test for using private methods in static field initializers
mkubilaykJan 26, 2021
7da5bd9
Add breaking checker test
mkubilaykJan 26, 2021
e133f60
Add to instances once per-instance
mkubilaykJan 26, 2021
aa5dd8a
Accept baseline
mkubilaykJan 26, 2021
a3889a7
fix: evaluate receiver and rhs expressions before throwing on readonl…
mkubilaykJan 26, 2021
8952caa
Add a test for evaluating rhs before readonly assignment
mkubilaykJan 26, 2021
dee87bb
Transpile private accessors
mkubilaykJan 27, 2021
aec7e9b
Accept baseline
mkubilaykJan 27, 2021
f3bbf0f
fix: handle readonly/writeonly accessors
mkubilaykJan 28, 2021
a1b59cd
accept baseline
mkubilaykJan 28, 2021
6b74498
add a test for private setter without a getter
mkubilaykJan 28, 2021
d51f6cd
fix: getAllUnscopedEmitHelpers
mkubilaykJan 28, 2021
c175770
fix: better handling of duplicate names
mkubilaykJan 29, 2021
4301af5
Fixed wrong error message for private methods in class expressions.
dragomirtitianFeb 1, 2021
3a056b2
change error message
mkubilaykFeb 1, 2021
95df2d1
add a test for async private methods with a higher target
mkubilaykFeb 1, 2021
590124e
fix: setter assignment returns rhs value
mkubilaykFeb 3, 2021
219ea83
add a test for setter assignment return value
mkubilaykFeb 3, 2021
25da8ca
fix: handle duplicate accessors
mkubilaykFeb 3, 2021
a2228be
add tests for duplicate accessors
mkubilaykFeb 3, 2021
ff4f737
docs: add missing parameter docs
mkubilaykFeb 3, 2021
704727c
Fixed failing test.
dragomirtitianFeb 3, 2021
73925dc
baseline-accept: ordering changes
mkubilaykFeb 17, 2021
67fd38d
fix: attach weakSetName to property declaration
mkubilaykFeb 17, 2021
45c2a41
add a test for nested private methods
mkubilaykFeb 17, 2021
356b91d
add a test with any
mkubilaykFeb 17, 2021
b391464
Merge pull request #51 from bloomberg/fix/nested-private-methods
dragomirtitianFeb 18, 2021
5ebb3d6
Added support for static private fields accessors and methods.
dragomirtitianFeb 16, 2021
7006c09
Added error message for private identifiers used with static decorato…
dragomirtitianFeb 16, 2021
b876613
Fixed emit static bug that used private names outside of classes for …
dragomirtitianFeb 18, 2021
31a8c00
Added tests for private static fields methods and accessors.
dragomirtitianFeb 18, 2021
9219e99
Merge remote-tracking branch 'remotes/origin/master' into es-private-…
dragomirtitianFeb 19, 2021
5a27a32
Merge remote-tracking branch 'remotes/bloomberg/es-private-methods-an…
dragomirtitianFeb 19, 2021
964fc27
Fixed error messages and tests after merge.
dragomirtitianFeb 19, 2021
d2ab6fc
Merge branch 'es-private-methods-and-accessors' into es-private-stati…
dragomirtitianFeb 19, 2021
23f6c67
Accept new baseline.
dragomirtitianFeb 19, 2021
374e6f3
Improved duplicate identifier checks for static private class elements.
dragomirtitianFeb 19, 2021
62b4f2f
Added error when using initializers with private static fields when u…
dragomirtitianFeb 23, 2021
b2a692d
Fixed code review issues.
dragomirtitianFeb 24, 2021
363041e
Removed semantically wrong emit on `useDefineForClassFields:true` wit…
dragomirtitianFeb 24, 2021
64757e0
Changed emit for uninitialized private static fields.
dragomirtitianFeb 25, 2021
68a7f80
Added runtime error in helper if a static private field is accessed b…
dragomirtitianFeb 25, 2021
7e7b0b1
Fixed code review comments for private identifier static class elements.
dragomirtitianFeb 25, 2021
30c7f69
add debug.assertNever for unknown node type (#53)
mkubilaykMar 1, 2021
c924058
Merge remote-tracking branch 'upstream/master' into es-private-method…
mkubilaykMar 1, 2021
e65116f
Merge remote-tracking branch 'upstream/master' into es-private-method…
mkubilaykMar 2, 2021
4748c87
Fixed code review issues.
dragomirtitianMar 3, 2021
09a5aae
Merge branch 'es-private-methods-and-accessors' into es-private-stati…
dragomirtitianMar 3, 2021
497e47f
Fixed code review issues for private class elements.
dragomirtitianMar 3, 2021
294cc48
Fixes class shadowing when checking access to a private static class …
dragomirtitianMar 8, 2021
027bdb3
Merge remote-tracking branch 'remotes/origin/master' into es-private-…
dragomirtitianMar 8, 2021
7bbc944
Merge remote-tracking branch 'upstream/master'
mkubilaykMar 17, 2021
dd526e7
fix private methods/accessors in class expr inside a loop
mkubilaykMar 17, 2021
f6ecfab
collapse switch case
mkubilaykMar 17, 2021
6c3f661
fix class name
mkubilaykMar 17, 2021
ef69c6c
simplify getPrivateMethodsAndAccessors
mkubilaykMar 17, 2021
2a646ed
remove findPreviousAccessorInfo
mkubilaykMar 17, 2021
d8136f7
lazily create weakSetName identifier
mkubilaykMar 17, 2021
fbd749c
Merge remote-tracking branch 'remotes/bloomberg/es-private-static-fie…
dragomirtitianMar 17, 2021
f96eafe
Merge remote-tracking branch 'remotes/bloomberg/es-private-static-fie…
dragomirtitianMar 17, 2021
2de8a43
Merge branch 'es-private-methods-and-accessors' of https://github.com…
dragomirtitianMar 18, 2021
7490a36
do not allocate a node if not needed in visitMehodDeclaration (#55)
mkubilaykMar 18, 2021
c273258
Removed all the emit helpers for private identifier methods accessors…
dragomirtitianMar 17, 2021
1addbb3
Simplified emit for private identifier class elements.
dragomirtitianMar 18, 2021
c461b92
do not clone the receiver (#57)
mkubilaykMar 18, 2021
a61fd5f
leave bad code in for #constructor and duplicate private names (#58)
mkubilaykMar 19, 2021
89f746a
Added check for WeakSet collision.
dragomirtitianMar 19, 2021
ff24636
Added error for using a set only accessor.
dragomirtitianMar 22, 2021
a60e429
Merge pull request #61 from bloomberg/es-private-methods-and-accessor…
dragomirtitianMar 22, 2021
f5816ab
update keyof tests and ?? (#62)
mkubilaykMar 23, 2021
3b62d3c
fix emit helpers comments
mkubilaykMar 23, 2021
7d8a2b9
produce an error if private field helpers are not up to date
mkubilaykMar 23, 2021
d0d2055
add tests
mkubilaykMar 23, 2021
93a7ca3
fix setter-only compound assignment
mkubilaykMar 23, 2021
6da2cdd
Merge pull request #63 from bloomberg/helper-parameter-count
mkubilaykMar 23, 2021
30805b7
fix tests
mkubilaykMar 23, 2021
8d77a8e
fix duplicated trailing comments (#64)
mkubilaykMar 24, 2021
8078ae0
clear receiver pos and setTextRange on helper calls
mkubilaykMar 24, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
PrevPrevious commit
NextNext commit
Accept baseline
Signed-off-by: Kubilay Kahveci <kahvecikubilay@gmail.com>
  • Loading branch information
@mkubilayk@dragomirtitian
mkubilayk authored anddragomirtitian committedFeb 3, 2021
commitaec7e9bd4b1a4f4bcbdca5e250e9a3fb9f334513
18 changes: 12 additions & 6 deletionstests/baselines/reference/privateNameAccessorsAccess.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,19 +26,25 @@ class B2 {


//// [privateNameAccessorsAccess.js]
var _A2_prop, _A2_prop_1;
var __classPrivateAccessorGet = (this && this.__classPrivateAccessorGet) || function (receiver, instances, fn) {
if (!instances.has(receiver)) {
throw new TypeError("attempted to get private accessor on non-instance");
}
return fn.call(receiver);
};
var _A2_prop_get, _A2_prop_set, _A2_instances;
class A2 {
constructor() {
console.log(this.);
_A2_instances.add(this);
console.log(__classPrivateAccessorGet(this, _A2_instances, _A2_prop_get));
let a = this;
a.;
__classPrivateAccessorGet(a, _A2_instances, _A2_prop_get);
function foo() {
a.;
__classPrivateAccessorGet(a, _A2_instances, _A2_prop_get);
}
}
get () { return ""; }
set (param) { }
}
_A2_instances = new WeakSet(), _A2_prop_get = function _A2_prop_get() { return ""; }, _A2_prop_set = function _A2_prop_set(param) { };
new A2().; // Error
function foo() {
new A2().; // Error
Expand Down
72 changes: 27 additions & 45 deletionstests/baselines/reference/privateNameAccessorsCallExpression.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,49 +18,31 @@ class A {
getInstance() { return new A(); }
}

tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.js(10,14): error TS1003: Identifier expected.
tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.js(11,27): error TS1003: Identifier expected.
tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.js(13,18): error TS1003: Identifier expected.
tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.js(15,14): error TS1003: Identifier expected.
tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.js(16,28): error TS1003: Identifier expected.
tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.js(17,26): error TS1003: Identifier expected.
tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.js(18,35): error TS1003: Identifier expected.


==== tests/cases/conformance/classes/members/privateNames/privateNameAccessorsCallExpression.js (7 errors) ====
var _A_fieldFunc, _A_fieldFunc2;
class A {
constructor() {
this.x = 1;
}
get () { return function () { this.x = 10; }; }
get () { return function (a, ...b) { }; }
test() {
var _a;
this..call(this);
~
!!! error TS1003: Identifier expected.
const func = this.;
~
!!! error TS1003: Identifier expected.
func();
new this.();
~
!!! error TS1003: Identifier expected.
const arr = [1, 2];
this..call(this, 0, ...arr, 3);
~
!!! error TS1003: Identifier expected.
const b = new this.(0, ...arr, 3);
~
!!! error TS1003: Identifier expected.
const str = this..bind(this) `head${1}middle${2}tail`;
~
!!! error TS1003: Identifier expected.
(_a = this.getInstance())..bind(_a) `test${1}and${2}`;
~
!!! error TS1003: Identifier expected.
}
getInstance() { return new A(); }
//// [privateNameAccessorsCallExpression.js]
var __classPrivateAccessorGet = (this && this.__classPrivateAccessorGet) || function (receiver, instances, fn) {
if (!instances.has(receiver)) {
throw new TypeError("attempted to get private accessor on non-instance");
}
return fn.call(receiver);
};
var _A_fieldFunc_get, _A_fieldFunc2_get, _A_instances;
class A {
constructor() {
_A_instances.add(this);
this.x = 1;
}

test() {
var _a;
__classPrivateAccessorGet(this, _A_instances, _A_fieldFunc_get).call(this);
const func = __classPrivateAccessorGet(this, _A_instances, _A_fieldFunc_get);
func();
new (__classPrivateAccessorGet(this, _A_instances, _A_fieldFunc_get))();
const arr = [1, 2];
__classPrivateAccessorGet(this, _A_instances, _A_fieldFunc2_get).call(this, 0, ...arr, 3);
const b = new (__classPrivateAccessorGet(this, _A_instances, _A_fieldFunc2_get))(0, ...arr, 3);
const str = __classPrivateAccessorGet(this, _A_instances, _A_fieldFunc2_get).bind(this) `head${1}middle${2}tail`;
__classPrivateAccessorGet((_a = this.getInstance()), _A_instances, _A_fieldFunc2_get).bind(_a) `test${1}and${2}`;
}
getInstance() { return new A(); }
}
_A_instances = new WeakSet(), _A_fieldFunc_get = function _A_fieldFunc_get() { return function () { this.x = 10; }; }, _A_fieldFunc2_get = function _A_fieldFunc2_get() { return function (a, ...b) { }; };
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,13 +13,22 @@ class Derived extends Base {


//// [privateNameAccessorssDerivedClasses.js]
var _Base_prop;
var __classPrivateAccessorGet = (this && this.__classPrivateAccessorGet) || function (receiver, instances, fn) {
if (!instances.has(receiver)) {
throw new TypeError("attempted to get private accessor on non-instance");
}
return fn.call(receiver);
};
var _Base_prop_get, _Base_instances;
class Base {
get () { return 123; }
constructor() {
_Base_instances.add(this);
}
static method(x) {
console.log(x.);
console.log(__classPrivateAccessorGet(x, _Base_instances, _Base_prop_get));
}
}
_Base_instances = new WeakSet(), _Base_prop_get = function _Base_prop_get() { return 123; };
class Derived extends Base {
static method(x) {
console.log(x.);
Expand Down
16 changes: 2 additions & 14 deletionstests/baselines/reference/privateNameES5Ban(target=es3).js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,20 +19,8 @@ var A = /** @class */ (function () {
_A_instances.add(this);
_A_field.set(this, 123);
}
Object.defineProperty(A.prototype, "", {
get: function () { return ""; },
set: function (x) { },
enumerable: false,
configurable: true
});
Object.defineProperty(A, "", {
get: function () { return 0; },
set: function (x) { },
enumerable: false,
configurable: true
});
var _A_field, _A_method, _A_sField, _A_sMethod, _A_acc, _A_acc_1, _A_sAcc, _A_sAcc_1, _A_instances;
_A_field = new WeakMap(), _A_sField = new WeakMap(), _A_instances = new WeakSet(), _A_method = function _A_method() { }, _A_sMethod = function _A_sMethod() { };
var _A_field, _A_method, _A_sField, _A_sMethod, _A_acc_get, _A_acc_set, _A_sAcc_get, _A_sAcc_set, _A_instances;
_A_field = new WeakMap(), _A_sField = new WeakMap(), _A_instances = new WeakSet(), _A_method = function _A_method() { }, _A_sMethod = function _A_sMethod() { }, _A_acc_get = function _A_acc_get() { return ""; }, _A_acc_set = function _A_acc_set(x) { }, _A_sAcc_get = function _A_sAcc_get() { return 0; }, _A_sAcc_set = function _A_sAcc_set(x) { };
_A_sField.set(A, "hello world");
return A;
}());
16 changes: 2 additions & 14 deletionstests/baselines/reference/privateNameES5Ban(target=es5).js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,20 +19,8 @@ var A = /** @class */ (function () {
_A_instances.add(this);
_A_field.set(this, 123);
}
Object.defineProperty(A.prototype, "", {
get: function () { return ""; },
set: function (x) { },
enumerable: false,
configurable: true
});
Object.defineProperty(A, "", {
get: function () { return 0; },
set: function (x) { },
enumerable: false,
configurable: true
});
var _A_field, _A_method, _A_sField, _A_sMethod, _A_acc, _A_acc_1, _A_sAcc, _A_sAcc_1, _A_instances;
_A_field = new WeakMap(), _A_sField = new WeakMap(), _A_instances = new WeakSet(), _A_method = function _A_method() { }, _A_sMethod = function _A_sMethod() { };
var _A_field, _A_method, _A_sField, _A_sMethod, _A_acc_get, _A_acc_set, _A_sAcc_get, _A_sAcc_set, _A_instances;
_A_field = new WeakMap(), _A_sField = new WeakMap(), _A_instances = new WeakSet(), _A_method = function _A_method() { }, _A_sMethod = function _A_sMethod() { }, _A_acc_get = function _A_acc_get() { return ""; }, _A_acc_set = function _A_acc_set(x) { }, _A_sAcc_get = function _A_sAcc_get() { return 0; }, _A_sAcc_set = function _A_sAcc_set(x) { };
_A_sField.set(A, "hello world");
return A;
}());
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -16,21 +16,31 @@ class Base {


//// [privateNameNestedClassAccessorsShadowing.js]
var _Base_x;
var __classPrivateAccessorGet = (this && this.__classPrivateAccessorGet) || function (receiver, instances, fn) {
if (!instances.has(receiver)) {
throw new TypeError("attempted to get private accessor on non-instance");
}
return fn.call(receiver);
};
var _Base_x_get, _Base_instances;
class Base {
constructor() {
var _Derived_x;
var _Derived_x_get, _Derived_instances;
_Base_instances.add(this);
class Derived {
get () { return 1; }
constructor() {
_Derived_instances.add(this);
}
;
testBase(x) {
console.log(x.);
console.log(__classPrivateAccessorGet(x, _Derived_instances, _Derived_x_get));
}
testDerived(x) {
console.log(x.);
console.log(__classPrivateAccessorGet(x, _Derived_instances, _Derived_x_get));
}
}
_Derived_instances = new WeakSet(), _Derived_x_get = function _Derived_x_get() { return 1; };
}
get () { return 1; }
;
}
_Base_instances = new WeakSet(), _Base_x_get = function _Base_x_get() { return 1; };
6 changes: 2 additions & 4 deletionstests/baselines/reference/privateNamesAndkeyof.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -13,7 +13,7 @@ type T = keyof A // should not include '#foo*'

//// [privateNamesAndkeyof.js]
"use strict";
var _A_fooField, _A_fooMethod,_A_fooProp, _A_fooProp_1, _A_instances;
var _A_fooField, _A_fooMethod,_A_fooProp_get, _A_fooProp_set, _A_instances;
class A {
constructor() {
_A_instances.add(this);
Expand All@@ -22,9 +22,7 @@ class A {
this.baz = 3;
}
;
get () { return 1; }
;
set (value) { }
;
}
_A_fooField = new WeakMap(), _A_instances = new WeakSet(), _A_fooMethod = function _A_fooMethod() { };
_A_fooField = new WeakMap(), _A_instances = new WeakSet(), _A_fooMethod = function _A_fooMethod() { }, _A_fooProp_get = function _A_fooProp_get() { return 1; }, _A_fooProp_set = function _A_fooProp_set(value) { };
18 changes: 11 additions & 7 deletionstests/baselines/reference/privateNamesInGenericClasses.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -48,25 +48,29 @@ var __classPrivateMethodGet = (this && this.__classPrivateMethodGet) || function
}
return fn;
};
var _C_foo, _C_method, _C_prop, _C_prop_1, _C_instances;
var __classPrivateAccessorGet = (this && this.__classPrivateAccessorGet) || function (receiver, instances, fn) {
if (!instances.has(receiver)) {
throw new TypeError("attempted to get private accessor on non-instance");
}
return fn.call(receiver);
};
var _C_foo, _C_method, _C_prop_get, _C_prop_set, _C_instances;
class C {
constructor() {
_C_instances.add(this);
_C_foo.set(this, void 0);
}
get () { return __classPrivateFieldGet(this, _C_foo); }
set (value) { __classPrivateFieldSet(this, _C_foo, value); }
bar(x) { return __classPrivateFieldGet(x, _C_foo); } // OK
bar2(x) { return __classPrivateMethodGet(x, _C_instances, _C_method).call(x); } // OK
bar3(x) { returnx.; } // OK
bar3(x) { return__classPrivateAccessorGet(x, _C_instances, _C_prop_get); } // OK
baz(x) { return __classPrivateFieldGet(x, _C_foo); } // OK
baz2(x) { return __classPrivateMethodGet(x, _C_instances, _C_method); } // OK
baz3(x) { returnx.; } // OK
baz3(x) { return__classPrivateAccessorGet(x, _C_instances, _C_prop_get); } // OK
quux(x) { return __classPrivateFieldGet(x, _C_foo); } // OK
quux2(x) { return __classPrivateMethodGet(x, _C_instances, _C_method); } // OK
quux3(x) { returnx.; } // OK
quux3(x) { return__classPrivateAccessorGet(x, _C_instances, _C_prop_get); } // OK
}
_C_foo = new WeakMap(), _C_instances = new WeakSet(), _C_method = function _C_method() { return __classPrivateFieldGet(this, _C_foo); };
_C_foo = new WeakMap(), _C_instances = new WeakSet(), _C_method = function _C_method() { return __classPrivateFieldGet(this, _C_foo); }, _C_prop_get = function _C_prop_get() { return __classPrivateFieldGet(this, _C_foo); }, _C_prop_set = function _C_prop_set(value) { __classPrivateFieldSet(this, _C_foo, value); };
a.; // Error
a.; // Error
a.; // Error
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -57,7 +57,7 @@ var __asyncGenerator = (this && this.__asyncGenerator) || function (thisArg, _ar
function reject(value) { resume("throw", value); }
function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
};
var _A_foo, _A_bar, _A_baz, _A_qux, _A_fooMethod, _A_barMethod, _A_bazMethod, _A_quxMethod, _A_asyncMethod, _A_genMethod, _A_asyncGenMethod,_A_fooProp, _A_fooProp_1, _A_barProp, _A_barProp_1, _A_bazProp, _A_bazProp_1, _A_quxProp, _A_quxProp_1, _A_whatProp, _A_whatProp_1, _A_asyncProp, _A_asyncProp_1, _A_instances;
var _A_foo, _A_bar, _A_baz, _A_qux, _A_fooMethod, _A_barMethod, _A_bazMethod, _A_quxMethod, _A_asyncMethod, _A_genMethod, _A_asyncGenMethod,_A_fooProp_get, _A_fooProp_set, _A_barProp_get, _A_barProp_set, _A_bazProp_get, _A_bazProp_set, _A_quxProp_get, _A_quxProp_set, _A_whatProp_get, _A_whatProp_set, _A_asyncProp_get, _A_asyncProp_set, _A_instances;
class A {
constructor() {
_A_instances.add(this);
Expand All@@ -66,21 +66,13 @@ class A {
_A_baz.set(this, 3); // Error
_A_qux.set(this, 3); // OK
}
get () { return 3; } // Error
set (value) { } // Error
get () { return 3; } // Error
set (value) { } // Error
get () { return 3; } // Error
set (value) { } // Error
get () { return 3; } // Error
set (value) { } // Error
get () { } // Error
set (value) { } // Error
get () { return 1; } // Error
set (value) { } // Error
}
_A_foo = new WeakMap(), _A_bar = new WeakMap(), _A_baz = new WeakMap(), _A_qux = new WeakMap(), _A_instances = new WeakSet(), _A_fooMethod = function _A_fooMethod() { return 3; }, _A_barMethod = function _A_barMethod() { return 3; }, _A_bazMethod = function _A_bazMethod() { return 3; }, _A_quxMethod = function _A_quxMethod() { return 3; }, _A_asyncMethod = function _A_asyncMethod() {
return __awaiter(this, void 0, void 0, function* () { return 1; });
}, _A_genMethod = function* _A_genMethod() { return 1; }, _A_asyncGenMethod = function _A_asyncGenMethod() { return __asyncGenerator(this, arguments, function* _A_asyncGenMethod_1() { return yield __await(1); }); };
}, _A_genMethod = function* _A_genMethod() { return 1; }, _A_asyncGenMethod = function _A_asyncGenMethod() { return __asyncGenerator(this, arguments, function* _A_asyncGenMethod_1() { return yield __await(1); }); }, _A_fooProp_get = function _A_fooProp_get() { return 3; }, _A_fooProp_set = function _A_fooProp_set(value) { }, _A_barProp_get = function _A_barProp_get() { return 3; }, _A_barProp_set = function _A_barProp_set(value) { }, _A_bazProp_get = function _A_bazProp_get() { return 3; }, _A_bazProp_set = function _A_bazProp_set(value) { }, _A_quxProp_get = function _A_quxProp_get() { return 3; }, _A_quxProp_set = function _A_quxProp_set(value) { }, _A_whatProp_get = function _A_whatProp_get() { }, _A_whatProp_set = function _A_whatProp_set(value) { }, _A_asyncProp_get = function _A_asyncProp_get() {
return __awaiter(this, void 0, void 0, function* () { return 1; });
}, _A_asyncProp_set = function _A_asyncProp_set(value) {
return __awaiter(this, void 0, void 0, function* () { });
};
class B {
}
14 changes: 10 additions & 4 deletionstests/baselines/reference/privateNamesUseBeforeDef.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -33,7 +33,13 @@ var __classPrivateMethodGet = (this && this.__classPrivateMethodGet) || function
}
return fn;
};
var _A_foo, _A_bar, _A2_foo, _A2_bar, _A2_instances, _A3_foo, _A3_bar, _B_foo, _B_bar;
var __classPrivateAccessorGet = (this && this.__classPrivateAccessorGet) || function (receiver, instances, fn) {
if (!instances.has(receiver)) {
throw new TypeError("attempted to get private accessor on non-instance");
}
return fn.call(receiver);
};
var _A_foo, _A_bar, _A2_foo, _A2_bar, _A2_instances, _A3_foo, _A3_bar_get, _A3_instances, _B_foo, _B_bar;
class A {
constructor() {
_A_foo.set(this, __classPrivateFieldGet(this, _A_bar)); // Error
Expand All@@ -51,12 +57,12 @@ class A2 {
_A2_foo = new WeakMap(), _A2_instances = new WeakSet(), _A2_bar = function _A2_bar() { return 3; };
class A3 {
constructor() {
_A3_foo.set(this, this.); // No Error
_A3_instances.add(this);
_A3_foo.set(this, __classPrivateAccessorGet(this, _A3_instances, _A3_bar_get)); // No Error
}
get () { return 3; }
;
}
_A3_foo = new WeakMap();
_A3_foo = new WeakMap(), _A3_instances = new WeakSet(), _A3_bar_get = function _A3_bar_get() { return 3; };
class B {
constructor() {
_B_foo.set(this, __classPrivateFieldGet(this, _B_bar)); // Error
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp