How to use PrivateIdentifier method in ts-auto-mock

Best JavaScript code snippet using ts-auto-mock

private_methods.ts

Source:private_methods.ts Github

copy

Full Screen

1import { Context } from '../../../src/common';2import { pass, fail } from '../../test-utils';3import * as t from 'assert';4import { parseSource } from '../../../src/parser';5describe('Next - Private methods', () => {6 fail('Private methods (fail)', [7 ['class A { #a }', Context.OptionsWebCompat],8 ['class A { #a }', Context.None],9 ['a = { #ab() {} }', Context.OptionsNext],10 ['class A { [{#ab() {}}]() {} }', Context.OptionsNext],11 ['class A{ # a() {}}', Context.OptionsNext],12 ['class C{ #method() { super(); } }', Context.OptionsNext],13 ['var o = { #m() {} };', Context.OptionsNext],14 ['var o = { async #m() {} };', Context.OptionsNext],15 ['var o = { *#m() {} };', Context.OptionsNext],16 ['class A { constructor = 4 }', Context.OptionsNext],17 ['class A { #constructor = 4 }', Context.OptionsNext],18 ['class A { a = () => super() }', Context.OptionsNext],19 ['class A { # a }', Context.OptionsNext],20 ['class A { #a; a() { this.# a } }', Context.OptionsNext],21 ['class A { #x; g = this.f; x = delete (g().#m); }', Context.OptionsNext],22 ['class A { #x; x = delete (this.#m); }', Context.OptionsNext],23 ['class A { #x; g = this.f; x = delete (g().#m); }', Context.OptionsNext],24 ['class A { #x; x = delete (g().#m); async *#m() {} }', Context.OptionsNext],25 ['class A { #x; x() { var g = this.f; delete g().#x; } }', Context.OptionsNext],26 ['class A { #x; x() { delete ((this.#m )); } async #m() {} }', Context.OptionsNext],27 ['class A { # x }', Context.OptionsNext],28 ['class A { #\\u0000; }', Context.OptionsNext],29 ['class A { * # m() {} }', Context.OptionsNext],30 ['class A { # x; }', Context.OptionsNext],31 ['class A { #x; m() { this.# x; }}', Context.OptionsNext],32 ['class A { # m() {} }', Context.OptionsNext],33 ['class A { static get # m() {} }', Context.OptionsNext],34 ['class A { * method() { super(); } }', Context.OptionsNext],35 ['class A { static async * prototype() {} }', Context.OptionsNext],36 ['class A { static async #method() { super(); } }', Context.OptionsNext],37 ['class A { method() { this.\\u0023field; } }', Context.OptionsNext],38 ['class C { static #x = super(); }', Context.OptionsNext],39 ['class C { async \\u0023m() {} } }', Context.OptionsNext],40 ['class C { static async *#gen() { var await; } }', Context.OptionsNext],41 ['class C { static async *#gen() { void await; } }', Context.OptionsNext],42 ['class C { static async *#gen() { var yield; } }', Context.OptionsNext],43 ['class C { static async *#gen() { void yield; } }', Context.OptionsNext],44 ['class C { static async *#gen() { yield: ; } }', Context.OptionsNext],45 ['class C { static async *#gen() { void \\u0061wait; } }', Context.OptionsNext],46 ['class C { async \\u0023m() {} } }', Context.OptionsNext],47 ['class C { #method() { a() { foo().\\u0023field; } } }', Context.OptionsNext],48 ['class C { #method() { \\u0023field; } }', Context.OptionsNext],49 ['class C { async \\u0023m() {} }', Context.OptionsNext],50 ['var C = class { x = 42 *gen() {} }', Context.OptionsNext],51 ['class Spaces { # wrongSpaces() { return fail(); } }', Context.OptionsNext],52 ['class C{ #method() { #[m] = 1} }', Context.OptionsNext],53 ['class C{ #method() { #"p" = x } }', Context.OptionsNext],54 ['class C{ #method() { super(); } }', Context.OptionsNext],55 ['(class C extends Base { async #*a() { } })', Context.OptionsNext],56 ['class C{ #method() { super(); } }', Context.OptionsNext],57 ['class C{ #method() { super(); } }', Context.OptionsNext],58 ['class C{ #method() { super(); } }', Context.OptionsNext],59 ['class C { #x = () => arguments; }', Context.OptionsNext]60 ]);61 for (const arg of [62 '#a : 0',63 '#a =',64 '#*a = 0',65 '#*a',66 '#constructor',67 'static #constructor',68 '#constructor = function() {}',69 '# a = 0',70 '#0 = 0;',71 '#0;',72 "#'a' = 0;",73 "#'a';",74 "#['a']",75 "#['a'] = 1",76 '#[a]',77 '#[a] = 1',78 '#a = arguments',79 'foo() { delete this.#a }',80 'foo() { delete this.x.#a }',81 'foo() { delete this.x().#a }',82 'foo() { delete f.#a }',83 'foo() { delete f.x.#a }',84 'foo() { delete f.x().#a }',85 '#a = 0\n *b(){}',86 "#a = 0\n ['b'](){}",87 'const { x: x } = this;',88 'var C = class { #x = 1; destructureX() { const { #x: x } = this; } };',89 'get # m() {}',90 'set # m(_) {}',91 'async * # m() {}',92 'async # m() {}',93 'm() { this.f().# x; }',94 '# x = 1;',95 '# x;',96 '* # m() {}',97 '# m() {}',98 'static get # m() {}',99 'async #*a() { }',100 '#x = () => /*{ initializer }*/;',101 '#x = /*{ initializer }*/;',102 '#x = false ? {} : /*{ initializer }*/;',103 '#x = typeof /*{ initializer }*/;',104 'static #x = /*{ initializer }*/;',105 '#x = () => super();',106 '#x = super();',107 '#\\u0000;'108 ]) {109 it(`class C { ${arg} }`, () => {110 t.throws(() => {111 parseSource(`class C { ${arg} }`, undefined, Context.OptionsNext);112 });113 });114 it(`class C extends Base { ${arg} }`, () => {115 t.throws(() => {116 parseSource(`class C extends Base { ${arg} }`, undefined, Context.OptionsNext);117 });118 });119 it(`(class C { ${arg} })`, () => {120 t.throws(() => {121 parseSource(`(class C { ${arg} })`, undefined, Context.OptionsNext);122 });123 });124 it(`(class C extends Base { ${arg} })`, () => {125 t.throws(() => {126 parseSource(`(class C extends Base { ${arg} })`, undefined, Context.OptionsNext);127 });128 });129 }130 for (const arg of [131 '#a = 0;',132 '#a = 0; #b;',133 '#a = 0; b;',134 '#a = 0; b(){}',135 '#a = 0; *b(){}',136 "#a = 0; ['b'](){}",137 '#a;',138 '#a; #b;',139 '#a; b;',140 '#a; b(){}',141 '#a; *b(){}',142 "#a; ['b'](){}",143 'async #a() { }',144 'static #prototype() {}',145 'static * #prototype() {}',146 'async *#a() { }',147 '#a = 0;\n',148 '#a = 0;\n #b;',149 '#a = 0;\n b;',150 '#a = 0;\n b(){}',151 '#a;\n',152 '#a;\n #b;\n',153 '#a;\n b;\n',154 '#a;\n b(){}',155 '#a;\n *b(){}',156 "#a;\n ['b'](){}",157 '#a;\n get;',158 '#get;\n *a(){}',159 '#a;\n static;',160 '#a = function t() { arguments; }',161 '#a = () => function() { arguments; }',162 '#yield;',163 '#yield = 0;',164 '#yield;\n a;',165 '#async;',166 '#async = 0;',167 '#async;',168 '#async = 0;',169 '#async;\n a(){}',170 '#async;\n a;',171 '#await;',172 '* #foo() {}',173 'async * #foo() {}',174 ' get #bar() {}',175 'set #baz(taz) {}',176 'static async foo() {}',177 'static foo() {}',178 'static ["foo"]() {}',179 'async *#foo() {}',180 '#await = 0;',181 '#await;\n a;',182 'foo() { this.#m, (() => this)().#m }',183 ' #_;',184 '#\u2118;',185 'foo() { this.#m, (() => this)().#m }',186 'foo() { this.#m, (() => this)().#m }',187 'foo() { this.#m, (() => this)().#m }',188 'foo() { this.#m, (() => this)().#m }',189 'method() { super.#x(); }'190 ]) {191 it(`class C { ${arg} }`, () => {192 t.doesNotThrow(() => {193 parseSource(`class C { ${arg} }`, undefined, Context.OptionsNext);194 });195 });196 it(`class C extends Base { ${arg} }`, () => {197 t.doesNotThrow(() => {198 parseSource(`class C extends Base { ${arg} }`, undefined, Context.OptionsNext);199 });200 });201 it(`(class C { ${arg} })`, () => {202 t.doesNotThrow(() => {203 parseSource(`(class C { ${arg} })`, undefined, Context.OptionsNext);204 });205 });206 it(`(class C extends Base { ${arg} })`, () => {207 t.doesNotThrow(() => {208 parseSource(`(class C extends Base { ${arg} })`, undefined, Context.OptionsNext);209 });210 });211 }212 for (const arg of [213 '{ class C { #a() { class B { #a() { } } new B; } } new C; }',214 '{ class A { #a() { class C extends A { #c() { } } new C; } } new A; }',215 '{ const C = class { #a() { } } }',216 '{ class A { constructor(arg) { return arg; } } class C extends A { #x() { } constructor(arg) { super(arg); } } let c1 = new C({}); }',217 'class D extends class { #c() {} } { #d() {} }',218 'class E extends D { #e() {} }',219 'var C = class { *m() { return 42; } #m() {}; method() { return this.#m(); } }',220 'var C = class { *m() { return 42; } static #$; static #_; static _(value) { this.#_ = value; return this.#_; }}',221 'var C = class { static async *m() { return 42; } static async * #$(value) { yield * await value; } }',222 'var C = class { static async *m() { return 42; } static async * #$(value) { yield * await value; } }',223 'var C = class { static async *m() { return 42; } static #$; static #_; }',224 'var C = class { static async m() { return 42; } #℘_; ℘(value) { this.#℘_ = value; return this.#℘; }}',225 'var C = class { static async m() { return 42; } static * #$(value) { yield * value; } static * #_(value) { yield * value; } }',226 'var C = class { static m() { return 42; } static #$ = 1; static #_ = 1; static _() { return this.#_; } }',227 'var C = class { var C = class { [obj1] = 42; [obj2] = 43; [obj3] = 44; } }',228 'var C = class { static m() { return 42; } static #$ = 1; static #_ = 1; static _() { return this.#_; } }',229 '{ class C { #a() { class B { #a() { } } new B; } } new C; }',230 `{231 {\n232 class A {\n233 #a() { return 1; }\n234 }\n235 \n236 new A;\n237 }\n238 {\n239 class D {\n240 #d() {}\n241 }\n242 \n243 class E extends D {\n244 #e() {}\n245 }\n246 \n247 new D;\n248 new E;\n249 }\n}`250 ]) {251 it(`${arg}`, () => {252 t.doesNotThrow(() => {253 parseSource(`${arg}`, undefined, Context.OptionsNext);254 });255 });256 }257 pass('Next - Private methods (pass)', [258 [259 `class A { #key; }`,260 Context.OptionsNext,261 {262 body: [263 {264 body: {265 body: [266 {267 computed: false,268 decorators: [],269 key: {270 name: 'key',271 type: 'PrivateIdentifier'272 },273 static: false,274 type: 'PropertyDefinition',275 value: null276 }277 ],278 type: 'ClassBody'279 },280 decorators: [],281 id: {282 name: 'A',283 type: 'Identifier'284 },285 superClass: null,286 type: 'ClassDeclaration'287 }288 ],289 sourceType: 'script',290 type: 'Program'291 }292 ],293 [294 `class A { static async #_(value) { return await value;} }`,295 Context.OptionsNext,296 {297 body: [298 {299 body: {300 body: [301 {302 computed: false,303 key: {304 name: '_',305 type: 'PrivateIdentifier'306 },307 decorators: [],308 kind: 'method',309 static: true,310 type: 'MethodDefinition',311 value: {312 async: true,313 body: {314 body: [315 {316 argument: {317 argument: {318 name: 'value',319 type: 'Identifier'320 },321 type: 'AwaitExpression'322 },323 type: 'ReturnStatement'324 }325 ],326 type: 'BlockStatement'327 },328 generator: false,329 id: null,330 params: [331 {332 name: 'value',333 type: 'Identifier'334 }335 ],336 type: 'FunctionExpression'337 }338 }339 ],340 type: 'ClassBody'341 },342 decorators: [],343 id: {344 name: 'A',345 type: 'Identifier'346 },347 superClass: null,348 type: 'ClassDeclaration'349 }350 ],351 sourceType: 'script',352 type: 'Program'353 }354 ],355 [356 `class A { #a; #b; }`,357 Context.OptionsNext | Context.OptionsRanges,358 {359 type: 'Program',360 sourceType: 'script',361 body: [362 {363 type: 'ClassDeclaration',364 decorators: [],365 id: {366 type: 'Identifier',367 name: 'A',368 start: 6,369 end: 7,370 range: [6, 7]371 },372 superClass: null,373 body: {374 type: 'ClassBody',375 body: [376 {377 type: 'PropertyDefinition',378 decorators: [],379 key: {380 type: 'PrivateIdentifier',381 name: 'a',382 start: 10,383 end: 12,384 range: [10, 12]385 },386 value: null,387 computed: false,388 static: false,389 start: 10,390 end: 12,391 range: [10, 12]392 },393 {394 type: 'PropertyDefinition',395 decorators: [],396 key: {397 type: 'PrivateIdentifier',398 name: 'b',399 start: 14,400 end: 16,401 range: [14, 16]402 },403 value: null,404 computed: false,405 static: false,406 start: 14,407 end: 16,408 range: [14, 16]409 }410 ],411 start: 8,412 end: 19,413 range: [8, 19]414 },415 start: 0,416 end: 19,417 range: [0, 19]418 }419 ],420 start: 0,421 end: 19,422 range: [0, 19]423 }424 ],425 [426 `class A { #yield = b[c]; }`,427 Context.OptionsNext | Context.OptionsRanges,428 {429 type: 'Program',430 sourceType: 'script',431 body: [432 {433 type: 'ClassDeclaration',434 decorators: [],435 id: {436 type: 'Identifier',437 name: 'A',438 start: 6,439 end: 7,440 range: [6, 7]441 },442 superClass: null,443 body: {444 type: 'ClassBody',445 body: [446 {447 type: 'PropertyDefinition',448 decorators: [],449 key: {450 type: 'PrivateIdentifier',451 name: 'yield',452 start: 10,453 end: 16,454 range: [10, 16]455 },456 value: {457 type: 'MemberExpression',458 object: {459 type: 'Identifier',460 name: 'b',461 start: 19,462 end: 20,463 range: [19, 20]464 },465 computed: true,466 property: {467 type: 'Identifier',468 name: 'c',469 start: 21,470 end: 22,471 range: [21, 22]472 },473 start: 19,474 end: 23,475 range: [19, 23]476 },477 computed: false,478 static: false,479 start: 10,480 end: 23,481 range: [10, 23]482 }483 ],484 start: 8,485 end: 26,486 range: [8, 26]487 },488 start: 0,489 end: 26,490 range: [0, 26]491 }492 ],493 start: 0,494 end: 26,495 range: [0, 26]496 }497 ],498 [499 `class A { #yield = foo + bar; }`,500 Context.OptionsNext | Context.OptionsRanges,501 {502 type: 'Program',503 sourceType: 'script',504 body: [505 {506 type: 'ClassDeclaration',507 decorators: [],508 id: {509 type: 'Identifier',510 name: 'A',511 start: 6,512 end: 7,513 range: [6, 7]514 },515 superClass: null,516 body: {517 type: 'ClassBody',518 body: [519 {520 type: 'PropertyDefinition',521 decorators: [],522 key: {523 type: 'PrivateIdentifier',524 name: 'yield',525 start: 10,526 end: 16,527 range: [10, 16]528 },529 value: {530 type: 'BinaryExpression',531 left: {532 type: 'Identifier',533 name: 'foo',534 start: 19,535 end: 22,536 range: [19, 22]537 },538 right: {539 type: 'Identifier',540 name: 'bar',541 start: 25,542 end: 28,543 range: [25, 28]544 },545 operator: '+',546 start: 19,547 end: 28,548 range: [19, 28]549 },550 computed: false,551 static: false,552 start: 10,553 end: 28,554 range: [10, 28]555 }556 ],557 start: 8,558 end: 31,559 range: [8, 31]560 },561 start: 0,562 end: 31,563 range: [0, 31]564 }565 ],566 start: 0,567 end: 31,568 range: [0, 31]569 }570 ],571 [572 `class A { #yield; }`,573 Context.OptionsNext | Context.OptionsRanges,574 {575 type: 'Program',576 sourceType: 'script',577 body: [578 {579 type: 'ClassDeclaration',580 decorators: [],581 id: {582 type: 'Identifier',583 name: 'A',584 start: 6,585 end: 7,586 range: [6, 7]587 },588 superClass: null,589 body: {590 type: 'ClassBody',591 body: [592 {593 type: 'PropertyDefinition',594 decorators: [],595 key: {596 type: 'PrivateIdentifier',597 name: 'yield',598 start: 10,599 end: 16,600 range: [10, 16]601 },602 value: null,603 computed: false,604 static: false,605 start: 10,606 end: 16,607 range: [10, 16]608 }609 ],610 start: 8,611 end: 19,612 range: [8, 19]613 },614 start: 0,615 end: 19,616 range: [0, 19]617 }618 ],619 start: 0,620 end: 19,621 range: [0, 19]622 }623 ],624 [625 `class C { static async *#gen() { yield { ...yield, y: 1, ...yield yield, }; } static get gen() { return this.#gen; } }`,626 Context.OptionsNext,627 {628 body: [629 {630 body: {631 body: [632 {633 computed: false,634 key: {635 name: 'gen',636 type: 'PrivateIdentifier'637 },638 kind: 'method',639 static: true,640 decorators: [],641 type: 'MethodDefinition',642 value: {643 async: true,644 body: {645 body: [646 {647 expression: {648 argument: {649 properties: [650 {651 argument: {652 argument: null,653 delegate: false,654 type: 'YieldExpression'655 },656 type: 'SpreadElement'657 },658 {659 computed: false,660 key: {661 name: 'y',662 type: 'Identifier'663 },664 kind: 'init',665 method: false,666 shorthand: false,667 type: 'Property',668 value: {669 type: 'Literal',670 value: 1671 }672 },673 {674 argument: {675 argument: {676 argument: null,677 delegate: false,678 type: 'YieldExpression'679 },680 delegate: false,681 type: 'YieldExpression'682 },683 type: 'SpreadElement'684 }685 ],686 type: 'ObjectExpression'687 },688 delegate: false,689 type: 'YieldExpression'690 },691 type: 'ExpressionStatement'692 }693 ],694 type: 'BlockStatement'695 },696 generator: true,697 id: null,698 params: [],699 type: 'FunctionExpression'700 }701 },702 {703 computed: false,704 decorators: [],705 key: {706 name: 'gen',707 type: 'Identifier'708 },709 kind: 'get',710 static: true,711 type: 'MethodDefinition',712 value: {713 async: false,714 body: {715 body: [716 {717 argument: {718 computed: false,719 object: {720 type: 'ThisExpression'721 },722 property: {723 name: 'gen',724 type: 'PrivateIdentifier'725 },726 type: 'MemberExpression'727 },728 type: 'ReturnStatement'729 }730 ],731 type: 'BlockStatement'732 },733 generator: false,734 id: null,735 params: [],736 type: 'FunctionExpression'737 }738 }739 ],740 type: 'ClassBody'741 },742 decorators: [],743 id: {744 name: 'C',745 type: 'Identifier'746 },747 superClass: null,748 type: 'ClassDeclaration'749 }750 ],751 sourceType: 'script',752 type: 'Program'753 }754 ],755 [756 `class C { static *#gen() { yield [...yield yield]; } static get gen() { return this.#gen; } }`,757 Context.OptionsNext,758 {759 body: [760 {761 body: {762 body: [763 {764 computed: false,765 key: {766 name: 'gen',767 type: 'PrivateIdentifier'768 },769 kind: 'method',770 static: true,771 decorators: [],772 type: 'MethodDefinition',773 value: {774 async: false,775 body: {776 body: [777 {778 expression: {779 argument: {780 elements: [781 {782 argument: {783 argument: {784 argument: null,785 delegate: false,786 type: 'YieldExpression'787 },788 delegate: false,789 type: 'YieldExpression'790 },791 type: 'SpreadElement'792 }793 ],794 type: 'ArrayExpression'795 },796 delegate: false,797 type: 'YieldExpression'798 },799 type: 'ExpressionStatement'800 }801 ],802 type: 'BlockStatement'803 },804 generator: true,805 id: null,806 params: [],807 type: 'FunctionExpression'808 }809 },810 {811 computed: false,812 decorators: [],813 key: {814 name: 'gen',815 type: 'Identifier'816 },817 kind: 'get',818 static: true,819 type: 'MethodDefinition',820 value: {821 async: false,822 body: {823 body: [824 {825 argument: {826 computed: false,827 object: {828 type: 'ThisExpression'829 },830 property: {831 name: 'gen',832 type: 'PrivateIdentifier'833 },834 type: 'MemberExpression'835 },836 type: 'ReturnStatement'837 }838 ],839 type: 'BlockStatement'840 },841 generator: false,842 id: null,843 params: [],844 type: 'FunctionExpression'845 }846 }847 ],848 type: 'ClassBody'849 },850 decorators: [],851 id: {852 name: 'C',853 type: 'Identifier'854 },855 superClass: null,856 type: 'ClassDeclaration'857 }858 ],859 sourceType: 'script',860 type: 'Program'861 }862 ],863 [864 `class C { get #℘() {} set #℘(x) {} a() { return this.#℘; } b(value) { this.#℘ = x; } };`,865 Context.OptionsNext,866 {867 body: [868 {869 body: {870 body: [871 {872 computed: false,873 key: {874 name: '℘',875 type: 'PrivateIdentifier'876 },877 kind: 'get',878 static: false,879 decorators: [],880 type: 'MethodDefinition',881 value: {882 async: false,883 body: {884 body: [],885 type: 'BlockStatement'886 },887 generator: false,888 id: null,889 params: [],890 type: 'FunctionExpression'891 }892 },893 {894 computed: false,895 key: {896 name: '℘',897 type: 'PrivateIdentifier'898 },899 kind: 'set',900 static: false,901 decorators: [],902 type: 'MethodDefinition',903 value: {904 async: false,905 body: {906 body: [],907 type: 'BlockStatement'908 },909 generator: false,910 id: null,911 params: [912 {913 name: 'x',914 type: 'Identifier'915 }916 ],917 type: 'FunctionExpression'918 }919 },920 {921 computed: false,922 decorators: [],923 key: {924 name: 'a',925 type: 'Identifier'926 },927 kind: 'method',928 static: false,929 type: 'MethodDefinition',930 value: {931 async: false,932 body: {933 body: [934 {935 argument: {936 computed: false,937 object: {938 type: 'ThisExpression'939 },940 property: {941 name: '℘',942 type: 'PrivateIdentifier'943 },944 type: 'MemberExpression'945 },946 type: 'ReturnStatement'947 }948 ],949 type: 'BlockStatement'950 },951 generator: false,952 id: null,953 params: [],954 type: 'FunctionExpression'955 }956 },957 {958 computed: false,959 decorators: [],960 key: {961 name: 'b',962 type: 'Identifier'963 },964 kind: 'method',965 static: false,966 type: 'MethodDefinition',967 value: {968 async: false,969 body: {970 body: [971 {972 expression: {973 left: {974 computed: false,975 object: {976 type: 'ThisExpression'977 },978 property: {979 name: '℘',980 type: 'PrivateIdentifier'981 },982 type: 'MemberExpression'983 },984 operator: '=',985 right: {986 name: 'x',987 type: 'Identifier'988 },989 type: 'AssignmentExpression'990 },991 type: 'ExpressionStatement'992 }993 ],994 type: 'BlockStatement'995 },996 generator: false,997 id: null,998 params: [999 {1000 name: 'value',1001 type: 'Identifier'1002 }1003 ],1004 type: 'FunctionExpression'1005 }1006 }1007 ],1008 type: 'ClassBody'1009 },1010 decorators: [],1011 id: {1012 name: 'C',1013 type: 'Identifier'1014 },1015 superClass: null,1016 type: 'ClassDeclaration'1017 },1018 {1019 type: 'EmptyStatement'1020 }1021 ],1022 sourceType: 'script',1023 type: 'Program'1024 }1025 ],1026 [1027 `class C { #m() { return 42; } get ref() { return this.#m; } }`,1028 Context.OptionsNext,1029 {1030 type: 'Program',1031 sourceType: 'script',1032 body: [1033 {1034 type: 'ClassDeclaration',1035 decorators: [],1036 id: {1037 type: 'Identifier',1038 name: 'C'1039 },1040 superClass: null,1041 body: {1042 type: 'ClassBody',1043 body: [1044 {1045 type: 'MethodDefinition',1046 kind: 'method',1047 static: false,1048 computed: false,1049 decorators: [],1050 key: {1051 type: 'PrivateIdentifier',1052 name: 'm'1053 },1054 value: {1055 type: 'FunctionExpression',1056 params: [],1057 body: {1058 type: 'BlockStatement',1059 body: [1060 {1061 type: 'ReturnStatement',1062 argument: {1063 type: 'Literal',1064 value: 421065 }1066 }1067 ]1068 },1069 async: false,1070 generator: false,1071 id: null1072 }1073 },1074 {1075 type: 'MethodDefinition',1076 kind: 'get',1077 static: false,1078 computed: false,1079 decorators: [],1080 key: {1081 type: 'Identifier',1082 name: 'ref'1083 },1084 value: {1085 type: 'FunctionExpression',1086 params: [],1087 body: {1088 type: 'BlockStatement',1089 body: [1090 {1091 type: 'ReturnStatement',1092 argument: {1093 type: 'MemberExpression',1094 object: {1095 type: 'ThisExpression'1096 },1097 computed: false,1098 property: {1099 type: 'PrivateIdentifier',1100 name: 'm'1101 }1102 }1103 }1104 ]1105 },1106 async: false,1107 generator: false,1108 id: null1109 }1110 }1111 ]1112 }1113 }1114 ]1115 }1116 ],1117 [1118 `class A { #foo = bar; }`,1119 Context.OptionsNext,1120 {1121 body: [1122 {1123 body: {1124 body: [1125 {1126 computed: false,1127 decorators: [],1128 key: {1129 name: 'foo',1130 type: 'PrivateIdentifier'1131 },1132 static: false,1133 type: 'PropertyDefinition',1134 value: {1135 name: 'bar',1136 type: 'Identifier'1137 }1138 }1139 ],1140 type: 'ClassBody'1141 },1142 decorators: [],1143 id: {1144 name: 'A',1145 type: 'Identifier'1146 },1147 superClass: null,1148 type: 'ClassDeclaration'1149 }1150 ],1151 sourceType: 'script',1152 type: 'Program'1153 }1154 ],1155 [1156 `class Cl {1157 #privateField = "top secret string";1158 constructor() {1159 this.publicField = "not secret string";1160 }1161 get #privateFieldValue() {1162 return this.#privateField;1163 }1164 set #privateFieldValue(newValue) {1165 this.#privateField = newValue;1166 }1167 publicGetPrivateField() {1168 return this.#privateFieldValue;1169 }1170 publicSetPrivateField(newValue) {1171 this.#privateFieldValue = newValue;1172 }1173 get publicFieldValue() {1174 return this.publicField;1175 }1176 set publicFieldValue(newValue) {1177 this.publicField = newValue;1178 }1179 testUpdates() {1180 this.#privateField = 0;1181 this.publicField = 0;1182 this.#privateFieldValue = this.#privateFieldValue++;1183 this.publicFieldValue = this.publicFieldValue++;1184 ++this.#privateFieldValue;1185 ++this.publicFieldValue;1186 this.#privateFieldValue += 1;1187 this.publicFieldValue += 1;1188 this.#privateFieldValue = -(this.#privateFieldValue ** this.#privateFieldValue);1189 this.publicFieldValue = -(this.publicFieldValue ** this.publicFieldValue);1190 }1191 }`,1192 Context.OptionsNext,1193 {1194 type: 'Program',1195 sourceType: 'script',1196 body: [1197 {1198 type: 'ClassDeclaration',1199 id: {1200 type: 'Identifier',1201 name: 'Cl'1202 },1203 superClass: null,1204 decorators: [],1205 body: {1206 type: 'ClassBody',1207 body: [1208 {1209 type: 'PropertyDefinition',1210 key: {1211 type: 'PrivateIdentifier',1212 name: 'privateField'1213 },1214 value: {1215 type: 'Literal',1216 value: 'top secret string'1217 },1218 static: false,1219 computed: false,1220 decorators: []1221 },1222 {1223 type: 'MethodDefinition',1224 kind: 'constructor',1225 static: false,1226 computed: false,1227 key: {1228 type: 'Identifier',1229 name: 'constructor'1230 },1231 decorators: [],1232 value: {1233 type: 'FunctionExpression',1234 params: [],1235 body: {1236 type: 'BlockStatement',1237 body: [1238 {1239 type: 'ExpressionStatement',1240 expression: {1241 type: 'AssignmentExpression',1242 left: {1243 type: 'MemberExpression',1244 object: {1245 type: 'ThisExpression'1246 },1247 computed: false,1248 property: {1249 type: 'Identifier',1250 name: 'publicField'1251 }1252 },1253 operator: '=',1254 right: {1255 type: 'Literal',1256 value: 'not secret string'1257 }1258 }1259 }1260 ]1261 },1262 async: false,1263 generator: false,1264 id: null1265 }1266 },1267 {1268 type: 'MethodDefinition',1269 kind: 'get',1270 static: false,1271 computed: false,1272 decorators: [],1273 key: {1274 type: 'PrivateIdentifier',1275 name: 'privateFieldValue'1276 },1277 value: {1278 type: 'FunctionExpression',1279 params: [],1280 body: {1281 type: 'BlockStatement',1282 body: [1283 {1284 type: 'ReturnStatement',1285 argument: {1286 type: 'MemberExpression',1287 object: {1288 type: 'ThisExpression'1289 },1290 computed: false,1291 property: {1292 type: 'PrivateIdentifier',1293 name: 'privateField'1294 }1295 }1296 }1297 ]1298 },1299 async: false,1300 generator: false,1301 id: null1302 }1303 },1304 {1305 type: 'MethodDefinition',1306 kind: 'set',1307 static: false,1308 computed: false,1309 decorators: [],1310 key: {1311 type: 'PrivateIdentifier',1312 name: 'privateFieldValue'1313 },1314 value: {1315 type: 'FunctionExpression',1316 params: [1317 {1318 type: 'Identifier',1319 name: 'newValue'1320 }1321 ],1322 body: {1323 type: 'BlockStatement',1324 body: [1325 {1326 type: 'ExpressionStatement',1327 expression: {1328 type: 'AssignmentExpression',1329 left: {1330 type: 'MemberExpression',1331 object: {1332 type: 'ThisExpression'1333 },1334 computed: false,1335 property: {1336 type: 'PrivateIdentifier',1337 name: 'privateField'1338 }1339 },1340 operator: '=',1341 right: {1342 type: 'Identifier',1343 name: 'newValue'1344 }1345 }1346 }1347 ]1348 },1349 async: false,1350 generator: false,1351 id: null1352 }1353 },1354 {1355 type: 'MethodDefinition',1356 kind: 'method',1357 static: false,1358 computed: false,1359 key: {1360 type: 'Identifier',1361 name: 'publicGetPrivateField'1362 },1363 decorators: [],1364 value: {1365 type: 'FunctionExpression',1366 params: [],1367 body: {1368 type: 'BlockStatement',1369 body: [1370 {1371 type: 'ReturnStatement',1372 argument: {1373 type: 'MemberExpression',1374 object: {1375 type: 'ThisExpression'1376 },1377 computed: false,1378 property: {1379 type: 'PrivateIdentifier',1380 name: 'privateFieldValue'1381 }1382 }1383 }1384 ]1385 },1386 async: false,1387 generator: false,1388 id: null1389 }1390 },1391 {1392 type: 'MethodDefinition',1393 kind: 'method',1394 static: false,1395 computed: false,1396 key: {1397 type: 'Identifier',1398 name: 'publicSetPrivateField'1399 },1400 decorators: [],1401 value: {1402 type: 'FunctionExpression',1403 params: [1404 {1405 type: 'Identifier',1406 name: 'newValue'1407 }1408 ],1409 body: {1410 type: 'BlockStatement',1411 body: [1412 {1413 type: 'ExpressionStatement',1414 expression: {1415 type: 'AssignmentExpression',1416 left: {1417 type: 'MemberExpression',1418 object: {1419 type: 'ThisExpression'1420 },1421 computed: false,1422 property: {1423 type: 'PrivateIdentifier',1424 name: 'privateFieldValue'1425 }1426 },1427 operator: '=',1428 right: {1429 type: 'Identifier',1430 name: 'newValue'1431 }1432 }1433 }1434 ]1435 },1436 async: false,1437 generator: false,1438 id: null1439 }1440 },1441 {1442 type: 'MethodDefinition',1443 kind: 'get',1444 static: false,1445 computed: false,1446 key: {1447 type: 'Identifier',1448 name: 'publicFieldValue'1449 },1450 decorators: [],1451 value: {1452 type: 'FunctionExpression',1453 params: [],1454 body: {1455 type: 'BlockStatement',1456 body: [1457 {1458 type: 'ReturnStatement',1459 argument: {1460 type: 'MemberExpression',1461 object: {1462 type: 'ThisExpression'1463 },1464 computed: false,1465 property: {1466 type: 'Identifier',1467 name: 'publicField'1468 }1469 }1470 }1471 ]1472 },1473 async: false,1474 generator: false,1475 id: null1476 }1477 },1478 {1479 type: 'MethodDefinition',1480 kind: 'set',1481 static: false,1482 computed: false,1483 key: {1484 type: 'Identifier',1485 name: 'publicFieldValue'1486 },1487 decorators: [],1488 value: {1489 type: 'FunctionExpression',1490 params: [1491 {1492 type: 'Identifier',1493 name: 'newValue'1494 }1495 ],1496 body: {1497 type: 'BlockStatement',1498 body: [1499 {1500 type: 'ExpressionStatement',1501 expression: {1502 type: 'AssignmentExpression',1503 left: {1504 type: 'MemberExpression',1505 object: {1506 type: 'ThisExpression'1507 },1508 computed: false,1509 property: {1510 type: 'Identifier',1511 name: 'publicField'1512 }1513 },1514 operator: '=',1515 right: {1516 type: 'Identifier',1517 name: 'newValue'1518 }1519 }1520 }1521 ]1522 },1523 async: false,1524 generator: false,1525 id: null1526 }1527 },1528 {1529 type: 'MethodDefinition',1530 kind: 'method',1531 static: false,1532 computed: false,1533 key: {1534 type: 'Identifier',1535 name: 'testUpdates'1536 },1537 decorators: [],1538 value: {1539 type: 'FunctionExpression',1540 params: [],1541 body: {1542 type: 'BlockStatement',1543 body: [1544 {1545 type: 'ExpressionStatement',1546 expression: {1547 type: 'AssignmentExpression',1548 left: {1549 type: 'MemberExpression',1550 object: {1551 type: 'ThisExpression'1552 },1553 computed: false,1554 property: {1555 type: 'PrivateIdentifier',1556 name: 'privateField'1557 }1558 },1559 operator: '=',1560 right: {1561 type: 'Literal',1562 value: 01563 }1564 }1565 },1566 {1567 type: 'ExpressionStatement',1568 expression: {1569 type: 'AssignmentExpression',1570 left: {1571 type: 'MemberExpression',1572 object: {1573 type: 'ThisExpression'1574 },1575 computed: false,1576 property: {1577 type: 'Identifier',1578 name: 'publicField'1579 }1580 },1581 operator: '=',1582 right: {1583 type: 'Literal',1584 value: 01585 }1586 }1587 },1588 {1589 type: 'ExpressionStatement',1590 expression: {1591 type: 'AssignmentExpression',1592 left: {1593 type: 'MemberExpression',1594 object: {1595 type: 'ThisExpression'1596 },1597 computed: false,1598 property: {1599 type: 'PrivateIdentifier',1600 name: 'privateFieldValue'1601 }1602 },1603 operator: '=',1604 right: {1605 type: 'UpdateExpression',1606 argument: {1607 type: 'MemberExpression',1608 object: {1609 type: 'ThisExpression'1610 },1611 computed: false,1612 property: {1613 type: 'PrivateIdentifier',1614 name: 'privateFieldValue'1615 }1616 },1617 operator: '++',1618 prefix: false1619 }1620 }1621 },1622 {1623 type: 'ExpressionStatement',1624 expression: {1625 type: 'AssignmentExpression',1626 left: {1627 type: 'MemberExpression',1628 object: {1629 type: 'ThisExpression'1630 },1631 computed: false,1632 property: {1633 type: 'Identifier',1634 name: 'publicFieldValue'1635 }1636 },1637 operator: '=',1638 right: {1639 type: 'UpdateExpression',1640 argument: {1641 type: 'MemberExpression',1642 object: {1643 type: 'ThisExpression'1644 },1645 computed: false,1646 property: {1647 type: 'Identifier',1648 name: 'publicFieldValue'1649 }1650 },1651 operator: '++',1652 prefix: false1653 }1654 }1655 },1656 {1657 type: 'ExpressionStatement',1658 expression: {1659 type: 'UpdateExpression',1660 argument: {1661 type: 'MemberExpression',1662 object: {1663 type: 'ThisExpression'1664 },1665 computed: false,1666 property: {1667 type: 'PrivateIdentifier',1668 name: 'privateFieldValue'1669 }1670 },1671 operator: '++',1672 prefix: true1673 }1674 },1675 {1676 type: 'ExpressionStatement',1677 expression: {1678 type: 'UpdateExpression',1679 argument: {1680 type: 'MemberExpression',1681 object: {1682 type: 'ThisExpression'1683 },1684 computed: false,1685 property: {1686 type: 'Identifier',1687 name: 'publicFieldValue'1688 }1689 },1690 operator: '++',1691 prefix: true1692 }1693 },1694 {1695 type: 'ExpressionStatement',1696 expression: {1697 type: 'AssignmentExpression',1698 left: {1699 type: 'MemberExpression',1700 object: {1701 type: 'ThisExpression'1702 },1703 computed: false,1704 property: {1705 type: 'PrivateIdentifier',1706 name: 'privateFieldValue'1707 }1708 },1709 operator: '+=',1710 right: {1711 type: 'Literal',1712 value: 11713 }1714 }1715 },1716 {1717 type: 'ExpressionStatement',1718 expression: {1719 type: 'AssignmentExpression',1720 left: {1721 type: 'MemberExpression',1722 object: {1723 type: 'ThisExpression'1724 },1725 computed: false,1726 property: {1727 type: 'Identifier',1728 name: 'publicFieldValue'1729 }1730 },1731 operator: '+=',1732 right: {1733 type: 'Literal',1734 value: 11735 }1736 }1737 },1738 {1739 type: 'ExpressionStatement',1740 expression: {1741 type: 'AssignmentExpression',1742 left: {1743 type: 'MemberExpression',1744 object: {1745 type: 'ThisExpression'1746 },1747 computed: false,1748 property: {1749 type: 'PrivateIdentifier',1750 name: 'privateFieldValue'1751 }1752 },1753 operator: '=',1754 right: {1755 type: 'UnaryExpression',1756 operator: '-',1757 argument: {1758 type: 'BinaryExpression',1759 left: {1760 type: 'MemberExpression',1761 object: {1762 type: 'ThisExpression'1763 },1764 computed: false,1765 property: {1766 type: 'PrivateIdentifier',1767 name: 'privateFieldValue'1768 }1769 },1770 right: {1771 type: 'MemberExpression',1772 object: {1773 type: 'ThisExpression'1774 },1775 computed: false,1776 property: {1777 type: 'PrivateIdentifier',1778 name: 'privateFieldValue'1779 }1780 },1781 operator: '**'1782 },1783 prefix: true1784 }1785 }1786 },1787 {1788 type: 'ExpressionStatement',1789 expression: {1790 type: 'AssignmentExpression',1791 left: {1792 type: 'MemberExpression',1793 object: {1794 type: 'ThisExpression'1795 },1796 computed: false,1797 property: {1798 type: 'Identifier',1799 name: 'publicFieldValue'1800 }1801 },1802 operator: '=',1803 right: {1804 type: 'UnaryExpression',1805 operator: '-',1806 argument: {1807 type: 'BinaryExpression',1808 left: {1809 type: 'MemberExpression',1810 object: {1811 type: 'ThisExpression'1812 },1813 computed: false,1814 property: {1815 type: 'Identifier',1816 name: 'publicFieldValue'1817 }1818 },1819 right: {1820 type: 'MemberExpression',1821 object: {1822 type: 'ThisExpression'1823 },1824 computed: false,1825 property: {1826 type: 'Identifier',1827 name: 'publicFieldValue'1828 }1829 },1830 operator: '**'1831 },1832 prefix: true1833 }1834 }1835 }1836 ]1837 },1838 async: false,1839 generator: false,1840 id: null1841 }1842 }1843 ]1844 }1845 }1846 ]1847 }1848 ],1849 [1850 `class Cl {1851 #privateField = 0;1852 get #privateFieldValue() {1853 return this.#privateField;1854 }1855 constructor() {1856 this.#privateFieldValue = 1;1857 }1858 }`,1859 Context.OptionsNext,1860 {1861 type: 'Program',1862 sourceType: 'script',1863 body: [1864 {1865 type: 'ClassDeclaration',1866 id: {1867 type: 'Identifier',1868 name: 'Cl'1869 },1870 superClass: null,1871 decorators: [],1872 body: {1873 type: 'ClassBody',1874 body: [1875 {1876 type: 'PropertyDefinition',1877 key: {1878 type: 'PrivateIdentifier',1879 name: 'privateField'1880 },1881 value: {1882 type: 'Literal',1883 value: 01884 },1885 static: false,1886 computed: false,1887 decorators: []1888 },1889 {1890 type: 'MethodDefinition',1891 kind: 'get',1892 static: false,1893 computed: false,1894 decorators: [],1895 key: {1896 type: 'PrivateIdentifier',1897 name: 'privateFieldValue'1898 },1899 value: {1900 type: 'FunctionExpression',1901 params: [],1902 body: {1903 type: 'BlockStatement',1904 body: [1905 {1906 type: 'ReturnStatement',1907 argument: {1908 type: 'MemberExpression',1909 object: {1910 type: 'ThisExpression'1911 },1912 computed: false,1913 property: {1914 type: 'PrivateIdentifier',1915 name: 'privateField'1916 }1917 }1918 }1919 ]1920 },1921 async: false,1922 generator: false,1923 id: null1924 }1925 },1926 {1927 type: 'MethodDefinition',1928 kind: 'constructor',1929 static: false,1930 computed: false,1931 key: {1932 type: 'Identifier',1933 name: 'constructor'1934 },1935 decorators: [],1936 value: {1937 type: 'FunctionExpression',1938 params: [],1939 body: {1940 type: 'BlockStatement',1941 body: [1942 {1943 type: 'ExpressionStatement',1944 expression: {1945 type: 'AssignmentExpression',1946 left: {1947 type: 'MemberExpression',1948 object: {1949 type: 'ThisExpression'1950 },1951 computed: false,1952 property: {1953 type: 'PrivateIdentifier',1954 name: 'privateFieldValue'1955 }1956 },1957 operator: '=',1958 right: {1959 type: 'Literal',1960 value: 11961 }1962 }1963 }1964 ]1965 },1966 async: false,1967 generator: false,1968 id: null1969 }1970 }1971 ]1972 }1973 }1974 ]1975 }1976 ],1977 [1978 `class Cl {1979 #privateField = "top secret string";1980 constructor() {1981 this.publicField = "not secret string";1982 }1983 get #privateFieldValue() {1984 return this.#privateField;1985 }1986 set #privateFieldValue(newValue) {1987 this.#privateField = newValue;1988 }1989 publicGetPrivateField() {1990 return this.#privateFieldValue;1991 }1992 publicSetPrivateField(newValue) {1993 this.#privateFieldValue = newValue;1994 }1995 } `,1996 Context.OptionsNext,1997 {1998 type: 'Program',1999 sourceType: 'script',2000 body: [2001 {2002 type: 'ClassDeclaration',2003 id: {2004 type: 'Identifier',2005 name: 'Cl'2006 },2007 superClass: null,2008 decorators: [],2009 body: {2010 type: 'ClassBody',2011 body: [2012 {2013 type: 'PropertyDefinition',2014 key: {2015 type: 'PrivateIdentifier',2016 name: 'privateField'2017 },2018 value: {2019 type: 'Literal',2020 value: 'top secret string'2021 },2022 static: false,2023 computed: false,2024 decorators: []2025 },2026 {2027 type: 'MethodDefinition',2028 kind: 'constructor',2029 static: false,2030 computed: false,2031 key: {2032 type: 'Identifier',2033 name: 'constructor'2034 },2035 decorators: [],2036 value: {2037 type: 'FunctionExpression',2038 params: [],2039 body: {2040 type: 'BlockStatement',2041 body: [2042 {2043 type: 'ExpressionStatement',2044 expression: {2045 type: 'AssignmentExpression',2046 left: {2047 type: 'MemberExpression',2048 object: {2049 type: 'ThisExpression'2050 },2051 computed: false,2052 property: {2053 type: 'Identifier',2054 name: 'publicField'2055 }2056 },2057 operator: '=',2058 right: {2059 type: 'Literal',2060 value: 'not secret string'2061 }2062 }2063 }2064 ]2065 },2066 async: false,2067 generator: false,2068 id: null2069 }2070 },2071 {2072 type: 'MethodDefinition',2073 kind: 'get',2074 static: false,2075 computed: false,2076 decorators: [],2077 key: {2078 type: 'PrivateIdentifier',2079 name: 'privateFieldValue'2080 },2081 value: {2082 type: 'FunctionExpression',2083 params: [],2084 body: {2085 type: 'BlockStatement',2086 body: [2087 {2088 type: 'ReturnStatement',2089 argument: {2090 type: 'MemberExpression',2091 object: {2092 type: 'ThisExpression'2093 },2094 computed: false,2095 property: {2096 type: 'PrivateIdentifier',2097 name: 'privateField'2098 }2099 }2100 }2101 ]2102 },2103 async: false,2104 generator: false,2105 id: null2106 }2107 },2108 {2109 type: 'MethodDefinition',2110 kind: 'set',2111 static: false,2112 computed: false,2113 decorators: [],2114 key: {2115 type: 'PrivateIdentifier',2116 name: 'privateFieldValue'2117 },2118 value: {2119 type: 'FunctionExpression',2120 params: [2121 {2122 type: 'Identifier',2123 name: 'newValue'2124 }2125 ],2126 body: {2127 type: 'BlockStatement',2128 body: [2129 {2130 type: 'ExpressionStatement',2131 expression: {2132 type: 'AssignmentExpression',2133 left: {2134 type: 'MemberExpression',2135 object: {2136 type: 'ThisExpression'2137 },2138 computed: false,2139 property: {2140 type: 'PrivateIdentifier',2141 name: 'privateField'2142 }2143 },2144 operator: '=',2145 right: {2146 type: 'Identifier',2147 name: 'newValue'2148 }2149 }2150 }2151 ]2152 },2153 async: false,2154 generator: false,2155 id: null2156 }2157 },2158 {2159 type: 'MethodDefinition',2160 kind: 'method',2161 static: false,2162 computed: false,2163 key: {2164 type: 'Identifier',2165 name: 'publicGetPrivateField'2166 },2167 decorators: [],2168 value: {2169 type: 'FunctionExpression',2170 params: [],2171 body: {2172 type: 'BlockStatement',2173 body: [2174 {2175 type: 'ReturnStatement',2176 argument: {2177 type: 'MemberExpression',2178 object: {2179 type: 'ThisExpression'2180 },2181 computed: false,2182 property: {2183 type: 'PrivateIdentifier',2184 name: 'privateFieldValue'2185 }2186 }2187 }2188 ]2189 },2190 async: false,2191 generator: false,2192 id: null2193 }2194 },2195 {2196 type: 'MethodDefinition',2197 kind: 'method',2198 static: false,2199 computed: false,2200 key: {2201 type: 'Identifier',2202 name: 'publicSetPrivateField'2203 },2204 decorators: [],2205 value: {2206 type: 'FunctionExpression',2207 params: [2208 {2209 type: 'Identifier',2210 name: 'newValue'2211 }2212 ],2213 body: {2214 type: 'BlockStatement',2215 body: [2216 {2217 type: 'ExpressionStatement',2218 expression: {2219 type: 'AssignmentExpression',2220 left: {2221 type: 'MemberExpression',2222 object: {2223 type: 'ThisExpression'2224 },2225 computed: false,2226 property: {2227 type: 'PrivateIdentifier',2228 name: 'privateFieldValue'2229 }2230 },2231 operator: '=',2232 right: {2233 type: 'Identifier',2234 name: 'newValue'2235 }2236 }2237 }2238 ]2239 },2240 async: false,2241 generator: false,2242 id: null2243 }2244 }2245 ]2246 }2247 }2248 ]2249 }2250 ],2251 [2252 `class A { #key() {} }`,2253 Context.OptionsNext,2254 {2255 type: 'Program',2256 sourceType: 'script',2257 body: [2258 {2259 type: 'ClassDeclaration',2260 decorators: [],2261 id: {2262 type: 'Identifier',2263 name: 'A'2264 },2265 superClass: null,2266 body: {2267 type: 'ClassBody',2268 body: [2269 {2270 type: 'MethodDefinition',2271 kind: 'method',2272 static: false,2273 computed: false,2274 decorators: [],2275 key: {2276 type: 'PrivateIdentifier',2277 name: 'key'2278 },2279 value: {2280 type: 'FunctionExpression',2281 params: [],2282 body: {2283 type: 'BlockStatement',2284 body: []2285 },2286 async: false,2287 generator: false,2288 id: null2289 }2290 }2291 ]2292 }2293 }2294 ]2295 }2296 ],2297 [2298 `class A { #yield\n = 0; }`,2299 Context.OptionsNext,2300 {2301 body: [2302 {2303 body: {2304 body: [2305 {2306 computed: false,2307 decorators: [],2308 key: {2309 name: 'yield',2310 type: 'PrivateIdentifier'2311 },2312 static: false,2313 type: 'PropertyDefinition',2314 value: {2315 type: 'Literal',2316 value: 02317 }2318 }2319 ],2320 type: 'ClassBody'2321 },2322 decorators: [],2323 id: {2324 name: 'A',2325 type: 'Identifier'2326 },2327 superClass: null,2328 type: 'ClassDeclaration'2329 }2330 ],2331 sourceType: 'script',2332 type: 'Program'2333 }2334 ],2335 [2336 `class A { #foo() { #bar } }`,2337 Context.OptionsNext,2338 {2339 type: 'Program',2340 sourceType: 'script',2341 body: [2342 {2343 type: 'ClassDeclaration',2344 decorators: [],2345 id: {2346 type: 'Identifier',2347 name: 'A'2348 },2349 superClass: null,2350 body: {2351 type: 'ClassBody',2352 body: [2353 {2354 type: 'MethodDefinition',2355 kind: 'method',2356 decorators: [],2357 static: false,2358 computed: false,2359 key: {2360 type: 'PrivateIdentifier',2361 name: 'foo'2362 },2363 value: {2364 type: 'FunctionExpression',2365 params: [],2366 body: {2367 type: 'BlockStatement',2368 body: [2369 {2370 type: 'ExpressionStatement',2371 expression: {2372 type: 'PrivateIdentifier',2373 name: 'bar'2374 }2375 }2376 ]2377 },2378 async: false,2379 generator: false,2380 id: null2381 }2382 }2383 ]2384 }2385 }2386 ]2387 }2388 ],2389 [2390 `class A { static #key; }`,2391 Context.OptionsNext,2392 {2393 body: [2394 {2395 body: {2396 body: [2397 {2398 computed: false,2399 decorators: [],2400 key: {2401 name: 'key',2402 type: 'PrivateIdentifier'2403 },2404 static: true,2405 type: 'PropertyDefinition',2406 value: null2407 }2408 ],2409 type: 'ClassBody'2410 },2411 decorators: [],2412 id: {2413 name: 'A',2414 type: 'Identifier'2415 },2416 superClass: null,2417 type: 'ClassDeclaration'2418 }2419 ],2420 sourceType: 'script',2421 type: 'Program'2422 }2423 ],2424 [2425 `class A { static #foo(bar) {} }`,2426 Context.OptionsNext,2427 {2428 body: [2429 {2430 body: {2431 body: [2432 {2433 computed: false,2434 decorators: [],2435 key: {2436 name: 'foo',2437 type: 'PrivateIdentifier'2438 },2439 kind: 'method',2440 static: true,2441 type: 'MethodDefinition',2442 value: {2443 async: false,2444 body: {2445 body: [],2446 type: 'BlockStatement'2447 },2448 generator: false,2449 id: null,2450 params: [2451 {2452 name: 'bar',2453 type: 'Identifier'2454 }2455 ],2456 type: 'FunctionExpression'2457 }2458 }2459 ],2460 type: 'ClassBody'2461 },2462 decorators: [],2463 id: {2464 name: 'A',2465 type: 'Identifier'2466 },2467 superClass: null,2468 type: 'ClassDeclaration'2469 }2470 ],2471 sourceType: 'script',2472 type: 'Program'2473 }2474 ],2475 [2476 `class A { m() {} #a; }`,2477 Context.OptionsNext,2478 {2479 body: [2480 {2481 body: {2482 body: [2483 {2484 computed: false,2485 decorators: [],2486 key: {2487 name: 'm',2488 type: 'Identifier'2489 },2490 kind: 'method',2491 static: false,2492 type: 'MethodDefinition',2493 value: {2494 async: false,2495 body: {2496 body: [],2497 type: 'BlockStatement'2498 },2499 generator: false,2500 id: null,2501 params: [],2502 type: 'FunctionExpression'2503 }2504 },2505 {2506 computed: false,2507 decorators: [],2508 key: {2509 name: 'a',2510 type: 'PrivateIdentifier'2511 },2512 static: false,2513 type: 'PropertyDefinition',2514 value: null2515 }2516 ],2517 type: 'ClassBody'2518 },2519 decorators: [],2520 id: {2521 name: 'A',2522 type: 'Identifier'2523 },2524 superClass: null,2525 type: 'ClassDeclaration'2526 }2527 ],2528 sourceType: 'script',2529 type: 'Program'2530 }2531 ],2532 [2533 `class A { #a; m() {} }`,2534 Context.OptionsNext,2535 {2536 body: [2537 {2538 body: {2539 body: [2540 {2541 computed: false,2542 decorators: [],2543 key: {2544 name: 'a',2545 type: 'PrivateIdentifier'2546 },2547 static: false,2548 type: 'PropertyDefinition',2549 value: null2550 },2551 {2552 computed: false,2553 decorators: [],2554 key: {2555 name: 'm',2556 type: 'Identifier'2557 },2558 kind: 'method',2559 static: false,2560 type: 'MethodDefinition',2561 value: {2562 async: false,2563 body: {2564 body: [],2565 type: 'BlockStatement'2566 },2567 generator: false,2568 id: null,2569 params: [],2570 type: 'FunctionExpression'2571 }2572 }2573 ],2574 type: 'ClassBody'2575 },2576 decorators: [],2577 id: {2578 name: 'A',2579 type: 'Identifier'2580 },2581 superClass: null,2582 type: 'ClassDeclaration'2583 }2584 ],2585 sourceType: 'script',2586 type: 'Program'2587 }2588 ],2589 [2590 `class A { #a; m() {} #b; }`,2591 Context.OptionsNext,2592 {2593 body: [2594 {2595 body: {2596 body: [2597 {2598 computed: false,2599 decorators: [],2600 key: {2601 name: 'a',2602 type: 'PrivateIdentifier'2603 },2604 static: false,2605 type: 'PropertyDefinition',2606 value: null2607 },2608 {2609 computed: false,2610 decorators: [],2611 key: {2612 name: 'm',2613 type: 'Identifier'2614 },2615 kind: 'method',2616 static: false,2617 type: 'MethodDefinition',2618 value: {2619 async: false,2620 body: {2621 body: [],2622 type: 'BlockStatement'2623 },2624 generator: false,2625 id: null,2626 params: [],2627 type: 'FunctionExpression'2628 }2629 },2630 {2631 computed: false,2632 decorators: [],2633 key: {2634 name: 'b',2635 type: 'PrivateIdentifier'2636 },2637 static: false,2638 type: 'PropertyDefinition',2639 value: null2640 }2641 ],2642 type: 'ClassBody'2643 },2644 decorators: [],2645 id: {2646 name: 'A',2647 type: 'Identifier'2648 },2649 superClass: null,2650 type: 'ClassDeclaration'2651 }2652 ],2653 sourceType: 'script',2654 type: 'Program'2655 }2656 ],2657 [2658 `class A { m() { return 42; } #a; #__; #NJ_; #℘_ ; }`,2659 Context.OptionsNext,2660 {2661 body: [2662 {2663 body: {2664 body: [2665 {2666 computed: false,2667 decorators: [],2668 key: {2669 name: 'm',2670 type: 'Identifier'2671 },2672 kind: 'method',2673 static: false,2674 type: 'MethodDefinition',2675 value: {2676 async: false,2677 body: {2678 body: [2679 {2680 argument: {2681 type: 'Literal',2682 value: 422683 },2684 type: 'ReturnStatement'2685 }2686 ],2687 type: 'BlockStatement'2688 },2689 generator: false,2690 id: null,2691 params: [],2692 type: 'FunctionExpression'2693 }2694 },2695 {2696 computed: false,2697 decorators: [],2698 key: {2699 name: 'a',2700 type: 'PrivateIdentifier'2701 },2702 static: false,2703 type: 'PropertyDefinition',2704 value: null2705 },2706 {2707 computed: false,2708 decorators: [],2709 key: {2710 name: '__',2711 type: 'PrivateIdentifier'2712 },2713 static: false,2714 type: 'PropertyDefinition',2715 value: null2716 },2717 {2718 computed: false,2719 decorators: [],2720 key: {2721 name: 'NJ_',2722 type: 'PrivateIdentifier'2723 },2724 static: false,2725 type: 'PropertyDefinition',2726 value: null2727 },2728 {2729 computed: false,2730 decorators: [],2731 key: {2732 name: '℘_',2733 type: 'PrivateIdentifier'2734 },2735 static: false,2736 type: 'PropertyDefinition',2737 value: null2738 }2739 ],2740 type: 'ClassBody'2741 },2742 decorators: [],2743 id: {2744 name: 'A',2745 type: 'Identifier'2746 },2747 superClass: null,2748 type: 'ClassDeclaration'2749 }2750 ],2751 sourceType: 'script',2752 type: 'Program'2753 }2754 ],2755 [2756 `class A { #foo = () => 'bar'; method() {2757 return this.#foo();2758 } }`,2759 Context.OptionsNext,2760 {2761 type: 'Program',2762 sourceType: 'script',2763 body: [2764 {2765 type: 'ClassDeclaration',2766 decorators: [],2767 id: {2768 type: 'Identifier',2769 name: 'A'2770 },2771 superClass: null,2772 body: {2773 type: 'ClassBody',2774 body: [2775 {2776 type: 'PropertyDefinition',2777 decorators: [],2778 key: {2779 type: 'PrivateIdentifier',2780 name: 'foo'2781 },2782 value: {2783 type: 'ArrowFunctionExpression',2784 body: {2785 type: 'Literal',2786 value: 'bar'2787 },2788 params: [],2789 async: false,2790 expression: true2791 },2792 computed: false,2793 static: false2794 },2795 {2796 type: 'MethodDefinition',2797 kind: 'method',2798 static: false,2799 computed: false,2800 decorators: [],2801 key: {2802 type: 'Identifier',2803 name: 'method'2804 },2805 value: {2806 type: 'FunctionExpression',2807 params: [],2808 body: {2809 type: 'BlockStatement',2810 body: [2811 {2812 type: 'ReturnStatement',2813 argument: {2814 type: 'CallExpression',2815 callee: {2816 type: 'MemberExpression',2817 object: {2818 type: 'ThisExpression'2819 },2820 computed: false,2821 property: {2822 type: 'PrivateIdentifier',2823 name: 'foo'2824 }2825 },2826 arguments: []2827 }2828 }2829 ]2830 },2831 async: false,2832 generator: false,2833 id: null2834 }2835 }2836 ]2837 }2838 }2839 ]2840 }2841 ],2842 [2843 `class B { #x = 0; #y = 1; }`,2844 Context.OptionsNext,2845 {2846 type: 'Program',2847 sourceType: 'script',2848 body: [2849 {2850 type: 'ClassDeclaration',2851 id: {2852 type: 'Identifier',2853 name: 'B'2854 },2855 superClass: null,2856 decorators: [],2857 body: {2858 type: 'ClassBody',2859 body: [2860 {2861 type: 'PropertyDefinition',2862 key: {2863 type: 'PrivateIdentifier',2864 name: 'x'2865 },2866 value: {2867 type: 'Literal',2868 value: 02869 },2870 static: false,2871 computed: false,2872 decorators: []2873 },2874 {2875 type: 'PropertyDefinition',2876 key: {2877 type: 'PrivateIdentifier',2878 name: 'y'2879 },2880 value: {2881 type: 'Literal',2882 value: 12883 },2884 static: false,2885 computed: false,2886 decorators: []2887 }2888 ]2889 }2890 }2891 ]2892 }2893 ],2894 [2895 `class A {2896 static #x;2897 static #y = 1;2898 }`,2899 Context.OptionsNext,2900 {2901 type: 'Program',2902 sourceType: 'script',2903 body: [2904 {2905 type: 'ClassDeclaration',2906 id: {2907 type: 'Identifier',2908 name: 'A'2909 },2910 superClass: null,2911 decorators: [],2912 body: {2913 type: 'ClassBody',2914 body: [2915 {2916 type: 'PropertyDefinition',2917 key: {2918 type: 'PrivateIdentifier',2919 name: 'x'2920 },2921 value: null,2922 static: true,2923 computed: false,2924 decorators: []2925 },2926 {2927 type: 'PropertyDefinition',2928 key: {2929 type: 'PrivateIdentifier',2930 name: 'y'2931 },2932 value: {2933 type: 'Literal',2934 value: 12935 },2936 static: true,2937 computed: false,2938 decorators: []2939 }2940 ]2941 }2942 }2943 ]2944 }2945 ],2946 [2947 `class A { #m = async function() { return 'foo'; }; method() { return this.#m(); } }`,2948 Context.OptionsNext,2949 {2950 body: [2951 {2952 body: {2953 body: [2954 {2955 computed: false,2956 decorators: [],2957 key: {2958 name: 'm',2959 type: 'PrivateIdentifier'2960 },2961 static: false,2962 type: 'PropertyDefinition',2963 value: {2964 async: true,2965 body: {2966 body: [2967 {2968 argument: {2969 type: 'Literal',2970 value: 'foo'2971 },2972 type: 'ReturnStatement'2973 }2974 ],2975 type: 'BlockStatement'2976 },2977 generator: false,2978 id: null,2979 params: [],2980 type: 'FunctionExpression'2981 }2982 },2983 {2984 computed: false,2985 decorators: [],2986 key: {2987 name: 'method',2988 type: 'Identifier'2989 },2990 kind: 'method',2991 static: false,2992 type: 'MethodDefinition',2993 value: {2994 async: false,2995 body: {2996 body: [2997 {2998 argument: {2999 arguments: [],3000 callee: {3001 computed: false,3002 object: {3003 type: 'ThisExpression'3004 },3005 property: {3006 name: 'm',3007 type: 'PrivateIdentifier'3008 },3009 type: 'MemberExpression'3010 },3011 type: 'CallExpression'3012 },3013 type: 'ReturnStatement'3014 }3015 ],3016 type: 'BlockStatement'3017 },3018 generator: false,3019 id: null,3020 params: [],3021 type: 'FunctionExpression'3022 }3023 }3024 ],3025 type: 'ClassBody'3026 },3027 decorators: [],3028 id: {3029 name: 'A',3030 type: 'Identifier'3031 },3032 superClass: null,3033 type: 'ClassDeclaration'3034 }3035 ],3036 sourceType: 'script',3037 type: 'Program'3038 }3039 ],3040 [3041 `class A { method() { return this.#m(); } #m = function () { return 'foo'; }; }`,3042 Context.OptionsNext,3043 {3044 body: [3045 {3046 body: {3047 body: [3048 {3049 computed: false,3050 decorators: [],3051 key: {3052 name: 'method',3053 type: 'Identifier'3054 },3055 kind: 'method',3056 static: false,3057 type: 'MethodDefinition',3058 value: {3059 async: false,3060 body: {3061 body: [3062 {3063 argument: {3064 arguments: [],3065 callee: {3066 computed: false,3067 object: {3068 type: 'ThisExpression'3069 },3070 property: {3071 name: 'm',3072 type: 'PrivateIdentifier'3073 },3074 type: 'MemberExpression'3075 },3076 type: 'CallExpression'3077 },3078 type: 'ReturnStatement'3079 }3080 ],3081 type: 'BlockStatement'3082 },3083 generator: false,3084 id: null,3085 params: [],3086 type: 'FunctionExpression'3087 }3088 },3089 {3090 computed: false,3091 decorators: [],3092 key: {3093 name: 'm',3094 type: 'PrivateIdentifier'3095 },3096 static: false,3097 type: 'PropertyDefinition',3098 value: {3099 async: false,3100 body: {3101 body: [3102 {3103 argument: {3104 type: 'Literal',3105 value: 'foo'3106 },3107 type: 'ReturnStatement'3108 }3109 ],3110 type: 'BlockStatement'3111 },3112 generator: false,3113 id: null,3114 params: [],3115 type: 'FunctionExpression'3116 }3117 }3118 ],3119 type: 'ClassBody'3120 },3121 decorators: [],3122 id: {3123 name: 'A',3124 type: 'Identifier'3125 },3126 superClass: null,3127 type: 'ClassDeclaration'3128 }3129 ],3130 sourceType: 'script',3131 type: 'Program'3132 }3133 ],3134 [3135 `class A { #m() { return 42; } get bGetter() { return this.#b; } #b = this.#m(); get ref() { return this.#m; } constructor() {} }`,3136 Context.OptionsNext,3137 {3138 body: [3139 {3140 body: {3141 body: [3142 {3143 computed: false,3144 decorators: [],3145 key: {3146 name: 'm',3147 type: 'PrivateIdentifier'3148 },3149 kind: 'method',3150 static: false,3151 type: 'MethodDefinition',3152 value: {3153 async: false,3154 body: {3155 body: [3156 {3157 argument: {3158 type: 'Literal',3159 value: 423160 },3161 type: 'ReturnStatement'3162 }3163 ],3164 type: 'BlockStatement'3165 },3166 generator: false,3167 id: null,3168 params: [],3169 type: 'FunctionExpression'3170 }3171 },3172 {3173 computed: false,3174 decorators: [],3175 key: {3176 name: 'bGetter',3177 type: 'Identifier'3178 },3179 kind: 'get',3180 static: false,3181 type: 'MethodDefinition',3182 value: {3183 async: false,3184 body: {3185 body: [3186 {3187 argument: {3188 computed: false,3189 object: {3190 type: 'ThisExpression'3191 },3192 property: {3193 name: 'b',3194 type: 'PrivateIdentifier'3195 },3196 type: 'MemberExpression'3197 },3198 type: 'ReturnStatement'3199 }3200 ],3201 type: 'BlockStatement'3202 },3203 generator: false,3204 id: null,3205 params: [],3206 type: 'FunctionExpression'3207 }3208 },3209 {3210 computed: false,3211 decorators: [],3212 key: {3213 name: 'b',3214 type: 'PrivateIdentifier'3215 },3216 static: false,3217 type: 'PropertyDefinition',3218 value: {3219 arguments: [],3220 callee: {3221 computed: false,3222 object: {3223 type: 'ThisExpression'3224 },3225 property: {3226 name: 'm',3227 type: 'PrivateIdentifier'3228 },3229 type: 'MemberExpression'3230 },3231 type: 'CallExpression'3232 }3233 },3234 {3235 computed: false,3236 decorators: [],3237 key: {3238 name: 'ref',3239 type: 'Identifier'3240 },3241 kind: 'get',3242 static: false,3243 type: 'MethodDefinition',3244 value: {3245 async: false,3246 body: {3247 body: [3248 {3249 argument: {3250 computed: false,3251 object: {3252 type: 'ThisExpression'3253 },3254 property: {3255 name: 'm',3256 type: 'PrivateIdentifier'3257 },3258 type: 'MemberExpression'3259 },3260 type: 'ReturnStatement'3261 }3262 ],3263 type: 'BlockStatement'3264 },3265 generator: false,3266 id: null,3267 params: [],3268 type: 'FunctionExpression'3269 }3270 },3271 {3272 computed: false,3273 decorators: [],3274 key: {3275 name: 'constructor',3276 type: 'Identifier'3277 },3278 kind: 'constructor',3279 static: false,3280 type: 'MethodDefinition',3281 value: {3282 async: false,3283 body: {3284 body: [],3285 type: 'BlockStatement'3286 },3287 generator: false,3288 id: null,3289 params: [],3290 type: 'FunctionExpression'3291 }3292 }3293 ],3294 type: 'ClassBody'3295 },3296 decorators: [],3297 id: {3298 name: 'A',3299 type: 'Identifier'3300 },3301 superClass: null,3302 type: 'ClassDeclaration'3303 }3304 ],3305 sourceType: 'script',3306 type: 'Program'3307 }3308 ],3309 [3310 `class A { #$_; #℘_; }`,3311 Context.OptionsNext,3312 {3313 body: [3314 {3315 body: {3316 body: [3317 {3318 computed: false,3319 decorators: [],3320 key: {3321 name: '$_',3322 type: 'PrivateIdentifier'3323 },3324 static: false,3325 type: 'PropertyDefinition',3326 value: null3327 },3328 {3329 computed: false,3330 decorators: [],3331 key: {3332 name: '℘_',3333 type: 'PrivateIdentifier'3334 },3335 static: false,3336 type: 'PropertyDefinition',3337 value: null3338 }3339 ],3340 type: 'ClassBody'3341 },3342 decorators: [],3343 id: {3344 name: 'A',3345 type: 'Identifier'3346 },3347 superClass: null,3348 type: 'ClassDeclaration'3349 }3350 ],3351 sourceType: 'script',3352 type: 'Program'3353 }3354 ],3355 [3356 `class A { $(value) { this.#$_ = value; return this.#$; } }`,3357 Context.OptionsNext,3358 {3359 body: [3360 {3361 body: {3362 body: [3363 {3364 computed: false,3365 decorators: [],3366 key: {3367 name: '$',3368 type: 'Identifier'3369 },3370 kind: 'method',3371 static: false,3372 type: 'MethodDefinition',3373 value: {3374 async: false,3375 body: {3376 body: [3377 {3378 expression: {3379 left: {3380 computed: false,3381 object: {3382 type: 'ThisExpression'3383 },3384 property: {3385 name: '$_',3386 type: 'PrivateIdentifier'3387 },3388 type: 'MemberExpression'3389 },3390 operator: '=',3391 right: {3392 name: 'value',3393 type: 'Identifier'3394 },3395 type: 'AssignmentExpression'3396 },3397 type: 'ExpressionStatement'3398 },3399 {3400 argument: {3401 computed: false,3402 object: {3403 type: 'ThisExpression'3404 },3405 property: {3406 name: '$',3407 type: 'PrivateIdentifier'3408 },3409 type: 'MemberExpression'3410 },3411 type: 'ReturnStatement'3412 }3413 ],3414 type: 'BlockStatement'3415 },3416 generator: false,3417 id: null,3418 params: [3419 {3420 name: 'value',3421 type: 'Identifier'3422 }3423 ],3424 type: 'FunctionExpression'3425 }3426 }3427 ],3428 type: 'ClassBody'3429 },3430 decorators: [],3431 id: {3432 name: 'A',3433 type: 'Identifier'3434 },3435 superClass: null,3436 type: 'ClassDeclaration'3437 }3438 ],3439 sourceType: 'script',3440 type: 'Program'3441 }3442 ],3443 [3444 `var C = class {3445 static *m() { return 42; } #$_; #__; #℘_; set #$(value) { this.#$_ = value;3446 }3447 set #_(value) {3448 this.#__ = value;3449 }3450 }`,3451 Context.OptionsNext,3452 {3453 type: 'Program',3454 sourceType: 'script',3455 body: [3456 {3457 type: 'VariableDeclaration',3458 kind: 'var',3459 declarations: [3460 {3461 type: 'VariableDeclarator',3462 init: {3463 type: 'ClassExpression',3464 id: null,3465 superClass: null,3466 decorators: [],3467 body: {3468 type: 'ClassBody',3469 body: [3470 {3471 type: 'MethodDefinition',3472 kind: 'method',3473 static: true,3474 computed: false,3475 key: {3476 type: 'Identifier',3477 name: 'm'3478 },3479 decorators: [],3480 value: {3481 type: 'FunctionExpression',3482 params: [],3483 body: {3484 type: 'BlockStatement',3485 body: [3486 {3487 type: 'ReturnStatement',3488 argument: {3489 type: 'Literal',3490 value: 423491 }3492 }3493 ]3494 },3495 async: false,3496 generator: true,3497 id: null3498 }3499 },3500 {3501 type: 'PropertyDefinition',3502 key: {3503 type: 'PrivateIdentifier',3504 name: '$_'3505 },3506 value: null,3507 static: false,3508 computed: false,3509 decorators: []3510 },3511 {3512 type: 'PropertyDefinition',3513 key: {3514 type: 'PrivateIdentifier',3515 name: '__'3516 },3517 value: null,3518 static: false,3519 computed: false,3520 decorators: []3521 },3522 {3523 type: 'PropertyDefinition',3524 key: {3525 type: 'PrivateIdentifier',3526 name: '℘_'3527 },3528 value: null,3529 static: false,3530 computed: false,3531 decorators: []3532 },3533 {3534 type: 'MethodDefinition',3535 kind: 'set',3536 static: false,3537 computed: false,3538 decorators: [],3539 key: {3540 type: 'PrivateIdentifier',3541 name: '$'3542 },3543 value: {3544 type: 'FunctionExpression',3545 params: [3546 {3547 type: 'Identifier',3548 name: 'value'3549 }3550 ],3551 body: {3552 type: 'BlockStatement',3553 body: [3554 {3555 type: 'ExpressionStatement',3556 expression: {3557 type: 'AssignmentExpression',3558 left: {3559 type: 'MemberExpression',3560 object: {3561 type: 'ThisExpression'3562 },3563 computed: false,3564 property: {3565 type: 'PrivateIdentifier',3566 name: '$_'3567 }3568 },3569 operator: '=',3570 right: {3571 type: 'Identifier',3572 name: 'value'3573 }3574 }3575 }3576 ]3577 },3578 async: false,3579 generator: false,3580 id: null3581 }3582 },3583 {3584 type: 'MethodDefinition',3585 kind: 'set',3586 static: false,3587 computed: false,3588 decorators: [],3589 key: {3590 type: 'PrivateIdentifier',3591 name: '_'3592 },3593 value: {3594 type: 'FunctionExpression',3595 params: [3596 {3597 type: 'Identifier',3598 name: 'value'3599 }3600 ],3601 body: {3602 type: 'BlockStatement',3603 body: [3604 {3605 type: 'ExpressionStatement',3606 expression: {3607 type: 'AssignmentExpression',3608 left: {3609 type: 'MemberExpression',3610 object: {3611 type: 'ThisExpression'3612 },3613 computed: false,3614 property: {3615 type: 'PrivateIdentifier',3616 name: '__'3617 }3618 },3619 operator: '=',3620 right: {3621 type: 'Identifier',3622 name: 'value'3623 }3624 }3625 }3626 ]3627 },3628 async: false,3629 generator: false,3630 id: null3631 }3632 }3633 ]3634 }3635 },3636 id: {3637 type: 'Identifier',3638 name: 'C'3639 }3640 }3641 ]3642 }3643 ]3644 }3645 ],3646 [3647 `class A { get #foo/*{ declareWith }*/() {} }`,3648 Context.OptionsNext,3649 {3650 body: [3651 {3652 body: {3653 body: [3654 {3655 computed: false,3656 decorators: [],3657 key: {3658 name: 'foo',3659 type: 'PrivateIdentifier'3660 },3661 kind: 'get',3662 static: false,3663 type: 'MethodDefinition',3664 value: {3665 async: false,3666 body: {3667 body: [],3668 type: 'BlockStatement'3669 },3670 generator: false,3671 id: null,3672 params: [],3673 type: 'FunctionExpression'3674 }3675 }3676 ],3677 type: 'ClassBody'3678 },3679 decorators: [],3680 id: {3681 name: 'A',3682 type: 'Identifier'3683 },3684 superClass: null,3685 type: 'ClassDeclaration'3686 }3687 ],3688 sourceType: 'script',3689 type: 'Program'3690 }3691 ],3692 [3693 `var C = class {3694 static async *m() { return 42; } #$_; #__;3695 get #_() {3696 return this.#__;3697 }3698 $(value) {3699 this.#$_ = value;3700 return this.#$;3701 }3702 _(value) {3703 this.#__ = value;3704 return this.#_;3705 }3706 }`,3707 Context.OptionsNext,3708 {3709 type: 'Program',3710 sourceType: 'script',3711 body: [3712 {3713 type: 'VariableDeclaration',3714 kind: 'var',3715 declarations: [3716 {3717 type: 'VariableDeclarator',3718 init: {3719 type: 'ClassExpression',3720 id: null,3721 superClass: null,3722 decorators: [],3723 body: {3724 type: 'ClassBody',3725 body: [3726 {3727 type: 'MethodDefinition',3728 kind: 'method',3729 static: true,3730 computed: false,3731 key: {3732 type: 'Identifier',3733 name: 'm'3734 },3735 decorators: [],3736 value: {3737 type: 'FunctionExpression',3738 params: [],3739 body: {3740 type: 'BlockStatement',3741 body: [3742 {3743 type: 'ReturnStatement',3744 argument: {3745 type: 'Literal',3746 value: 423747 }3748 }3749 ]3750 },3751 async: true,3752 generator: true,3753 id: null3754 }3755 },3756 {3757 type: 'PropertyDefinition',3758 key: {3759 type: 'PrivateIdentifier',3760 name: '$_'3761 },3762 value: null,3763 static: false,3764 computed: false,3765 decorators: []3766 },3767 {3768 type: 'PropertyDefinition',3769 key: {3770 type: 'PrivateIdentifier',3771 name: '__'3772 },3773 value: null,3774 static: false,3775 computed: false,3776 decorators: []3777 },3778 {3779 type: 'MethodDefinition',3780 kind: 'get',3781 static: false,3782 computed: false,3783 decorators: [],3784 key: {3785 type: 'PrivateIdentifier',3786 name: '_'3787 },3788 value: {3789 type: 'FunctionExpression',3790 params: [],3791 body: {3792 type: 'BlockStatement',3793 body: [3794 {3795 type: 'ReturnStatement',3796 argument: {3797 type: 'MemberExpression',3798 object: {3799 type: 'ThisExpression'3800 },3801 computed: false,3802 property: {3803 type: 'PrivateIdentifier',3804 name: '__'3805 }3806 }3807 }3808 ]3809 },3810 async: false,3811 generator: false,3812 id: null3813 }3814 },3815 {3816 type: 'MethodDefinition',3817 kind: 'method',3818 static: false,3819 computed: false,3820 key: {3821 type: 'Identifier',3822 name: '$'3823 },3824 decorators: [],3825 value: {3826 type: 'FunctionExpression',3827 params: [3828 {3829 type: 'Identifier',3830 name: 'value'3831 }3832 ],3833 body: {3834 type: 'BlockStatement',3835 body: [3836 {3837 type: 'ExpressionStatement',3838 expression: {3839 type: 'AssignmentExpression',3840 left: {3841 type: 'MemberExpression',3842 object: {3843 type: 'ThisExpression'3844 },3845 computed: false,3846 property: {3847 type: 'PrivateIdentifier',3848 name: '$_'3849 }3850 },3851 operator: '=',3852 right: {3853 type: 'Identifier',3854 name: 'value'3855 }3856 }3857 },3858 {3859 type: 'ReturnStatement',3860 argument: {3861 type: 'MemberExpression',3862 object: {3863 type: 'ThisExpression'3864 },3865 computed: false,3866 property: {3867 type: 'PrivateIdentifier',3868 name: '$'3869 }3870 }3871 }3872 ]3873 },3874 async: false,3875 generator: false,3876 id: null3877 }3878 },3879 {3880 type: 'MethodDefinition',3881 kind: 'method',3882 static: false,3883 computed: false,3884 key: {3885 type: 'Identifier',3886 name: '_'3887 },3888 decorators: [],3889 value: {3890 type: 'FunctionExpression',3891 params: [3892 {3893 type: 'Identifier',3894 name: 'value'3895 }3896 ],3897 body: {3898 type: 'BlockStatement',3899 body: [3900 {3901 type: 'ExpressionStatement',3902 expression: {3903 type: 'AssignmentExpression',3904 left: {3905 type: 'MemberExpression',3906 object: {3907 type: 'ThisExpression'3908 },3909 computed: false,3910 property: {3911 type: 'PrivateIdentifier',3912 name: '__'3913 }3914 },3915 operator: '=',3916 right: {3917 type: 'Identifier',3918 name: 'value'3919 }3920 }3921 },3922 {3923 type: 'ReturnStatement',3924 argument: {3925 type: 'MemberExpression',3926 object: {3927 type: 'ThisExpression'3928 },3929 computed: false,3930 property: {3931 type: 'PrivateIdentifier',3932 name: '_'3933 }3934 }3935 }3936 ]3937 },3938 async: false,3939 generator: false,3940 id: null3941 }3942 }3943 ]3944 }3945 },3946 id: {3947 type: 'Identifier',3948 name: 'C'3949 }3950 }3951 ]3952 }3953 ]3954 }3955 ],3956 [3957 `class Hotel {3958 get #evil() {3959 return ohNo();3960 }3961 set #evil(x) {3962 return makeEvil(x);3963 }3964 }`,3965 Context.OptionsNext,3966 {3967 type: 'Program',3968 sourceType: 'script',3969 body: [3970 {3971 type: 'ClassDeclaration',3972 id: {3973 type: 'Identifier',3974 name: 'Hotel'3975 },3976 superClass: null,3977 decorators: [],3978 body: {3979 type: 'ClassBody',3980 body: [3981 {3982 type: 'MethodDefinition',3983 kind: 'get',3984 static: false,3985 computed: false,3986 decorators: [],3987 key: {3988 type: 'PrivateIdentifier',3989 name: 'evil'3990 },3991 value: {3992 type: 'FunctionExpression',3993 params: [],3994 body: {3995 type: 'BlockStatement',3996 body: [3997 {3998 type: 'ReturnStatement',3999 argument: {4000 type: 'CallExpression',4001 callee: {4002 type: 'Identifier',4003 name: 'ohNo'4004 },4005 arguments: []4006 }4007 }4008 ]4009 },4010 async: false,4011 generator: false,4012 id: null4013 }4014 },4015 {4016 type: 'MethodDefinition',4017 kind: 'set',4018 static: false,4019 computed: false,4020 decorators: [],4021 key: {4022 type: 'PrivateIdentifier',4023 name: 'evil'4024 },4025 value: {4026 type: 'FunctionExpression',4027 params: [4028 {4029 type: 'Identifier',4030 name: 'x'4031 }4032 ],4033 body: {4034 type: 'BlockStatement',4035 body: [4036 {4037 type: 'ReturnStatement',4038 argument: {4039 type: 'CallExpression',4040 callee: {4041 type: 'Identifier',4042 name: 'makeEvil'4043 },4044 arguments: [4045 {4046 type: 'Identifier',4047 name: 'x'4048 }4049 ]4050 }4051 }4052 ]4053 },4054 async: false,4055 generator: false,4056 id: null4057 }4058 }4059 ]4060 }4061 }4062 ]4063 }4064 ],4065 [4066 `var C = class {4067 ;;;;4068 ;;;;;;;;;;;;;4069 ;;;;4070 static #x(value) {4071 return value / 2;4072 }4073 static #y(value) {4074 return value * 2;4075 }4076 static x() {4077 return this.#x(84);4078 }4079 static y() {4080 return this.#y(43);4081 }4082 } `,4083 Context.OptionsNext,4084 {4085 body: [4086 {4087 declarations: [4088 {4089 id: {4090 name: 'C',4091 type: 'Identifier'4092 },4093 init: {4094 body: {4095 body: [4096 {4097 computed: false,4098 decorators: [],4099 key: {4100 name: 'x',4101 type: 'PrivateIdentifier'4102 },4103 kind: 'method',4104 static: true,4105 type: 'MethodDefinition',4106 value: {4107 async: false,4108 body: {4109 body: [4110 {4111 argument: {4112 left: {4113 name: 'value',4114 type: 'Identifier'4115 },4116 operator: '/',4117 right: {4118 type: 'Literal',4119 value: 24120 },4121 type: 'BinaryExpression'4122 },4123 type: 'ReturnStatement'4124 }4125 ],4126 type: 'BlockStatement'4127 },4128 generator: false,4129 id: null,4130 params: [4131 {4132 name: 'value',4133 type: 'Identifier'4134 }4135 ],4136 type: 'FunctionExpression'4137 }4138 },4139 {4140 computed: false,4141 decorators: [],4142 key: {4143 name: 'y',4144 type: 'PrivateIdentifier'4145 },4146 kind: 'method',4147 static: true,4148 type: 'MethodDefinition',4149 value: {4150 async: false,4151 body: {4152 body: [4153 {4154 argument: {4155 left: {4156 name: 'value',4157 type: 'Identifier'4158 },4159 operator: '*',4160 right: {4161 type: 'Literal',4162 value: 24163 },4164 type: 'BinaryExpression'4165 },4166 type: 'ReturnStatement'4167 }4168 ],4169 type: 'BlockStatement'4170 },4171 generator: false,4172 id: null,4173 params: [4174 {4175 name: 'value',4176 type: 'Identifier'4177 }4178 ],4179 type: 'FunctionExpression'4180 }4181 },4182 {4183 computed: false,4184 decorators: [],4185 key: {4186 name: 'x',4187 type: 'Identifier'4188 },4189 kind: 'method',4190 static: true,4191 type: 'MethodDefinition',4192 value: {4193 async: false,4194 body: {4195 body: [4196 {4197 argument: {4198 arguments: [4199 {4200 type: 'Literal',4201 value: 844202 }4203 ],4204 callee: {4205 computed: false,4206 object: {4207 type: 'ThisExpression'4208 },4209 property: {4210 name: 'x',4211 type: 'PrivateIdentifier'4212 },4213 type: 'MemberExpression'4214 },4215 type: 'CallExpression'4216 },4217 type: 'ReturnStatement'4218 }4219 ],4220 type: 'BlockStatement'4221 },4222 generator: false,4223 id: null,4224 params: [],4225 type: 'FunctionExpression'4226 }4227 },4228 {4229 computed: false,4230 decorators: [],4231 key: {4232 name: 'y',4233 type: 'Identifier'4234 },4235 kind: 'method',4236 static: true,4237 type: 'MethodDefinition',4238 value: {4239 async: false,4240 body: {4241 body: [4242 {4243 argument: {4244 arguments: [4245 {4246 type: 'Literal',4247 value: 434248 }4249 ],4250 callee: {4251 computed: false,4252 object: {4253 type: 'ThisExpression'4254 },4255 property: {4256 name: 'y',4257 type: 'PrivateIdentifier'4258 },4259 type: 'MemberExpression'4260 },4261 type: 'CallExpression'4262 },4263 type: 'ReturnStatement'4264 }4265 ],4266 type: 'BlockStatement'4267 },4268 generator: false,4269 id: null,4270 params: [],4271 type: 'FunctionExpression'4272 }4273 }4274 ],4275 type: 'ClassBody'4276 },4277 decorators: [],4278 id: null,4279 superClass: null,4280 type: 'ClassExpression'4281 },4282 type: 'VariableDeclarator'4283 }4284 ],4285 kind: 'var',4286 type: 'VariableDeclaration'4287 }4288 ],4289 sourceType: 'script',4290 type: 'Program'4291 }4292 ],4293 [4294 `class A { static set #foo/*{ declareWith }*/(param) {} }`,4295 Context.OptionsNext,4296 {4297 body: [4298 {4299 body: {4300 body: [4301 {4302 computed: false,4303 decorators: [],4304 key: {4305 name: 'foo',4306 type: 'PrivateIdentifier'4307 },4308 kind: 'set',4309 static: true,4310 type: 'MethodDefinition',4311 value: {4312 async: false,4313 body: {4314 body: [],4315 type: 'BlockStatement'4316 },4317 generator: false,4318 id: null,4319 params: [4320 {4321 name: 'param',4322 type: 'Identifier'4323 }4324 ],4325 type: 'FunctionExpression'4326 }4327 }4328 ],4329 type: 'ClassBody'4330 },4331 decorators: [],4332 id: {4333 name: 'A',4334 type: 'Identifier'4335 },4336 superClass: null,4337 type: 'ClassDeclaration'4338 }4339 ],4340 sourceType: 'script',4341 type: 'Program'4342 }4343 ]4344 ]);...

Full Screen

Full Screen

MethodDefinition.ts

Source:MethodDefinition.ts Github

copy

Full Screen

1import { CallOptions } from '../CallOptions';2import { HasEffectsContext } from '../ExecutionContext';3import { EMPTY_PATH, ObjectPath } from '../utils/PathTracker';4import FunctionExpression from './FunctionExpression';5import * as NodeType from './NodeType';6import PrivateIdentifier from './PrivateIdentifier';7import { ExpressionNode, NodeBase } from './shared/Node';8export default class MethodDefinition extends NodeBase {9 computed!: boolean;10 key!: ExpressionNode | PrivateIdentifier;11 kind!: 'constructor' | 'method' | 'get' | 'set';12 static!: boolean;13 type!: NodeType.tMethodDefinition;14 value!: FunctionExpression;15 hasEffects(context: HasEffectsContext) {16 return this.key.hasEffects(context);17 }18 hasEffectsWhenCalledAtPath(19 path: ObjectPath,20 callOptions: CallOptions,21 context: HasEffectsContext22 ) {23 return (24 path.length > 0 || this.value.hasEffectsWhenCalledAtPath(EMPTY_PATH, callOptions, context)25 );26 }...

Full Screen

Full Screen

PropertyDefinition.ts

Source:PropertyDefinition.ts Github

copy

Full Screen

1import { HasEffectsContext } from '../ExecutionContext';2import * as NodeType from './NodeType';3import PrivateIdentifier from './PrivateIdentifier';4import { ExpressionNode, NodeBase } from './shared/Node';5export default class PropertyDefinition extends NodeBase {6 computed!: boolean;7 key!: ExpressionNode | PrivateIdentifier;8 static!: boolean;9 type!: NodeType.tPropertyDefinition;10 value!: ExpressionNode | null;11 hasEffects(context: HasEffectsContext): boolean {12 return (13 this.key.hasEffects(context) ||14 (this.static && this.value !== null && this.value.hasEffects(context))15 );16 }...

Full Screen

Full Screen

Using AI Code Generation

copy

Full Screen

1import { PrivateIdentifier } from 'ts-auto-mock';2import { PrivateIdentifier } from 'ts-auto-mock';3import { PrivateIdentifier } from 'ts-auto-mock';4import { PrivateIdentifier } from 'ts-auto-mock';5import { PrivateIdentifier } from 'ts-auto-mock';6import { PrivateIdentifier } from 'ts-auto-mock';7import { PrivateIdentifier } from 'ts-auto-mock';8import { PrivateIdentifier } from 'ts-auto-mock';9import { PrivateIdentifier } from 'ts-auto-mock';10import { PrivateIdentifier } from 'ts-auto-mock';11import { PrivateIdentifier } from 'ts-auto-mock';12import { PrivateIdentifier } from 'ts-auto-mock';13import { PrivateIdentifier } from 'ts-auto-mock';14import { PrivateIdentifier } from 'ts-auto-mock';15import { PrivateIdentifier } from 'ts-auto-mock';16import { PrivateIdentifier } from 'ts-auto-mock';

Full Screen

Using AI Code Generation

copy

Full Screen

1import { PrivateIdentifier } from 'ts-auto-mock';2import { createMock } from 'ts-auto-mock';3import { mock, when } from 'ts-mockito';4import { mockImport } from 'ts-mock-imports';5import { mock, when } from 'ts-mockito';6import { mockImport } from 'ts-mock-imports';7import { mock, when } from 'ts-mockito';8import { mockImport } from 'ts-mock-imports';9import { mock, when } from 'ts-mockito';10import { mockImport } from 'ts-mock-imports';11import { mock, when } from 'ts-mockito';12import { mockImport } from 'ts-mock-imports';13import { mock, when } from 'ts-mockito';14import { mockImport } from 'ts-mock-imports';15import { mock, when } from 'ts-mockito';16import { mockImport } from 'ts-mock-imports';17import { mock, when } from 'ts-mockito';18import { mockImport } from 'ts-mock-imports';19import { mock, when } from 'ts-mockito';20import { mockImport } from 'ts-mock-imports';21import { mock, when } from 'ts-mockito';22import { mockImport } from 'ts-mock-imports';23import { mock, when }

Full Screen

Using AI Code Generation

copy

Full Screen

1import {PrivateIdentifier} from 'ts-auto-mock/extension';2import {Foo} from './test2';3describe('test', () => {4 it('test', () => {5 const foo = new Foo();6 expect(PrivateIdentifier(foo, 'bar')).toBe('bar');7 });8});9export class Foo {10 #bar = 'bar';11}

Full Screen

Using AI Code Generation

copy

Full Screen

1import {Mock} from 'ts-auto-mock';2const mock:PrivateIdentifier = new Mock<PrivateIdentifier>().getMock();3mock.#a = 'b';4console.log(mock.#a);5console.log(mock.#b);6console.log(mock.#c);7console.log(mock.#d);8console.log(mock.#e);9console.log(mock.#f);10console.log(mock.#g);11console.log(mock.#h);12console.log(mock.#i);13console.log(mock.#j);14console.log(mock.#k);15console.log(mock.#l);16console.log(mock.#m);17console.log(mock.#n);18console.log(mock.#o);19console.log(mock.#p);20console.log(mock.#q);21console.log(mock.#r);22console.log(mock.#s);23console.log(mock.#t);24console.log(mock.#u);25console.log(mock.#v);26console.log(mock.#w);

Full Screen

Using AI Code Generation

copy

Full Screen

1import {PrivateIdentifier} from 'ts-auto-mock/extension';2import {MyClass} from './myClass';3const myClass = new MyClass();4const privateIdentifier = new PrivateIdentifier(myClass);5privateIdentifier.setPrivate('_myPrivateField', 'test');6import {PrivateIdentifier} from 'ts-auto-mock/extension';7import {MyClass} from './myClass';8const myClass = new MyClass();9const privateIdentifier = new PrivateIdentifier(myClass);10privateIdentifier.getPrivate('_myPrivateField');

Full Screen

Using AI Code Generation

copy

Full Screen

1import { PrivateIdentifier } from 'ts-auto-mock/extension';2import { Test2 } from './test2';3const mock = PrivateIdentifier<Test2>(Test2);4console.log(mock);5import { PrivateIdentifier } from 'ts-auto-mock/extension';6import { Test3 } from './test3';7const mock = PrivateIdentifier<Test3>(Test3);8console.log(mock);9import { PrivateIdentifier } from 'ts-auto-mock/extension';10import { Test1 } from './test1';11const mock = PrivateIdentifier<Test1>(Test1);12console.log(mock);13To fix this issue, you can use the ts-auto-mock/extension/no-import module instead. This module will not import the ts-auto-mock module, which means you can import ts-auto-mock in your project. For example, the above code can be rewritten as follows:14import { PrivateIdentifier } from 'ts-auto-mock/extension/no-import';15import { Test2 } from './test2';16import { Test3 } from './test3';17const mock = PrivateIdentifier<Test2>(Test2);18console.log(mock);19import { PrivateIdentifier } from 'ts-auto-mock/extension/no-import';20import { Test3 } from './test3';21import { Test1 } from './test1';

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run ts-auto-mock automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful