@@ -77,21 +77,6 @@ describe('private method transform validation', () => {
7777 expect ( result . code ) . toContain ( '#methodC' ) ;
7878 } ) ;
7979
80- test ( 'throws error when user-defined method collides with reserved prefix' , ( ) => {
81- const source = `
82- import { LightningElement } from 'lwc';
83- export default class Test extends LightningElement {
84- __lwc_component_class_internal_private_sneakyMethod() {
85- return 'collision';
86- }
87- }
88- ` ;
89-
90- expect ( ( ) => transformWithFullPipeline ( source ) ) . toThrowError (
91- / c a n n o t s t a r t w i t h r e s e r v e d p r e f i x ` _ _ l w c _ ` \. P l e a s e r e n a m e t h i s f u n c t i o n t o a v o i d c o n f l i c t /
92- ) ;
93- } ) ;
94-
9580 test ( 'throws error when collision exists alongside real private methods' , ( ) => {
9681 const source = `
9782 import { LightningElement } from 'lwc';
@@ -124,21 +109,6 @@ describe('private method transform validation', () => {
124109 expect ( result . code ) . toContain ( '_underscoreMethod' ) ;
125110 } ) ;
126111
127- test ( 'async private method round-trips successfully' , ( ) => {
128- const source = `
129- import { LightningElement } from 'lwc';
130- export default class Test extends LightningElement {
131- async #fetchData() {
132- return await Promise.resolve(42);
133- }
134- }
135- ` ;
136-
137- const result = transformWithFullPipeline ( source ) ;
138- expect ( result . code ) . toContain ( 'async #fetchData' ) ;
139- expect ( result . code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
140- } ) ;
141-
142112 test ( 'static private method round-trips successfully' , ( ) => {
143113 const source = `
144114 import { LightningElement } from 'lwc';
@@ -154,68 +124,6 @@ describe('private method transform validation', () => {
154124 expect ( result . code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
155125 } ) ;
156126
157- test ( 'private method with parameters round-trips successfully' , ( ) => {
158- const source = `
159- import { LightningElement } from 'lwc';
160- export default class Test extends LightningElement {
161- #compute(a, b, ...rest) {
162- return a + b + rest.length;
163- }
164- }
165- ` ;
166-
167- const result = transformWithFullPipeline ( source ) ;
168- expect ( result . code ) . toContain ( '#compute(a, b, ...rest)' ) ;
169- expect ( result . code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
170- } ) ;
171-
172- test ( 'private getter throws unsupported error' , ( ) => {
173- const source = `
174- import { LightningElement } from 'lwc';
175- export default class Test extends LightningElement {
176- get #value() {
177- return this._val;
178- }
179- }
180- ` ;
181-
182- expect ( ( ) => transformWithFullPipeline ( source ) ) . toThrowError (
183- / P r i v a t e a c c e s s o r m e t h o d s a r e n o t c u r r e n t l y s u p p o r t e d \. O n l y p r i v a t e m e t h o d s a r e s u p p o r t e d \. /
184- ) ;
185- } ) ;
186-
187- test ( 'private setter throws unsupported error' , ( ) => {
188- const source = `
189- import { LightningElement } from 'lwc';
190- export default class Test extends LightningElement {
191- set #value(v) {
192- this._val = v;
193- }
194- }
195- ` ;
196-
197- expect ( ( ) => transformWithFullPipeline ( source ) ) . toThrowError (
198- / P r i v a t e a c c e s s o r m e t h o d s a r e n o t c u r r e n t l y s u p p o r t e d \. O n l y p r i v a t e m e t h o d s a r e s u p p o r t e d \. /
199- ) ;
200- } ) ;
201-
202- test ( 'decorated private method throws' , ( ) => {
203- const source = `
204- import { LightningElement, api } from 'lwc';
205- export default class Test extends LightningElement {
206- @api #decorated() {
207- return 1;
208- }
209- }
210- ` ;
211-
212- // The forward private method transform runs as a separate plugin before the
213- // main LWC plugin, so LWC1212 fires before the @api decorator validation.
214- expect ( ( ) => transformWithFullPipeline ( source ) ) . toThrowError (
215- / D e c o r a t o r s c a n n o t b e a p p l i e d t o p r i v a t e m e t h o d s /
216- ) ;
217- } ) ;
218-
219127 test ( 'class with zero private methods succeeds' , ( ) => {
220128 const source = `
221129 import { LightningElement } from 'lwc';
@@ -260,23 +168,6 @@ describe('private method transform validation', () => {
260168 ) ;
261169 } ) ;
262170
263- test ( 'generator private method round-trips successfully' , ( ) => {
264- const source = `
265- import { LightningElement } from 'lwc';
266- export default class Test extends LightningElement {
267- *#generate() {
268- yield 1;
269- yield 2;
270- }
271- }
272- ` ;
273-
274- const result = transformWithFullPipeline ( source ) ;
275- expect ( result . code ) . toContain ( '#generate' ) ;
276- expect ( result . code ) . toContain ( 'yield' ) ;
277- expect ( result . code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
278- } ) ;
279-
280171 test ( 'reverse standalone on clean code succeeds without forward metadata' , ( ) => {
281172 const source = `
282173 class Test {
@@ -339,23 +230,6 @@ describe('private method transform validation', () => {
339230 ) . toThrowError ( / P r i v a t e m e t h o d t r a n s f o r m c o u n t m i s m a t c h / ) ;
340231 } ) ;
341232
342- test ( 'multiple classes in the same file round-trip private methods' , ( ) => {
343- const source = `
344- import { LightningElement } from 'lwc';
345- export default class First extends LightningElement {
346- #shared() { return 'first'; }
347- }
348- class Second extends LightningElement {
349- #shared() { return 'second'; }
350- }
351- ` ;
352-
353- const result = transformWithFullPipeline ( source ) ;
354- expect ( result . code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
355- const matches = result . code ! . match ( / # s h a r e d / g) ;
356- expect ( matches ) . toHaveLength ( 2 ) ;
357- } ) ;
358-
359233 test ( 'private method body with call sites round-trips' , ( ) => {
360234 const source = `
361235 import { LightningElement } from 'lwc';
@@ -431,72 +305,6 @@ describe('private method transform validation', () => {
431305 expect ( gammaIdx ) . toBeLessThan ( deltaIdx ) ;
432306 } ) ;
433307
434- test ( 'default parameter values survive round-trip' , ( ) => {
435- const source = `
436- import { LightningElement } from 'lwc';
437- export default class Test extends LightningElement {
438- #greet(name = 'world', times = 3) {
439- return name.repeat(times);
440- }
441- }
442- ` ;
443-
444- const result = transformWithFullPipeline ( source ) ;
445- const code = result . code ! ;
446- expect ( code ) . toContain ( '#greet' ) ;
447- expect ( code ) . toContain ( "'world'" ) ;
448- expect ( code ) . toContain ( '3' ) ;
449- expect ( code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
450- } ) ;
451-
452- test ( 'destructuring parameters survive round-trip' , ( ) => {
453- const source = `
454- import { LightningElement } from 'lwc';
455- export default class Test extends LightningElement {
456- #process({ x, y }, [a, b]) {
457- return x + y + a + b;
458- }
459- }
460- ` ;
461-
462- const result = transformWithFullPipeline ( source ) ;
463- const code = result . code ! ;
464- expect ( code ) . toContain ( '#process' ) ;
465- expect ( code ) . toMatch ( / \{ \s * x , \s * y \s * \} / ) ;
466- expect ( code ) . toMatch ( / \[ \s * a , \s * b \s * \] / ) ;
467- expect ( code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
468- } ) ;
469-
470- test ( 'empty method body round-trips' , ( ) => {
471- const source = `
472- import { LightningElement } from 'lwc';
473- export default class Test extends LightningElement {
474- #noop() {}
475- }
476- ` ;
477-
478- const result = transformWithFullPipeline ( source ) ;
479- expect ( result . code ) . toContain ( '#noop' ) ;
480- expect ( result . code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
481- } ) ;
482-
483- test ( 'private and public method with same name coexist' , ( ) => {
484- const source = `
485- import { LightningElement } from 'lwc';
486- export default class Test extends LightningElement {
487- #foo() { return 'private'; }
488- foo() { return 'public'; }
489- }
490- ` ;
491-
492- const result = transformWithFullPipeline ( source ) ;
493- const code = result . code ! ;
494- expect ( code ) . toContain ( '#foo' ) ;
495- expect ( code ) . toContain ( "return 'private'" ) ;
496- expect ( code ) . toContain ( "return 'public'" ) ;
497- expect ( code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
498- } ) ;
499-
500308 test ( 'intermediate plugin that modifies method body does not break reverse transform' , ( ) => {
501309 function bodyModifierPlugin ( { types : t } : any ) {
502310 return {
@@ -601,35 +409,6 @@ describe('private method transform validation', () => {
601409 expect ( code ) . not . toContain ( '#foo' ) ;
602410 } ) ;
603411
604- test ( 'private field throws unsupported error' , ( ) => {
605- const source = `
606- import { LightningElement } from 'lwc';
607- export default class Test extends LightningElement {
608- #count = 0;
609- }
610- ` ;
611-
612- expect ( ( ) => transformWithFullPipeline ( source ) ) . toThrowError (
613- / P r i v a t e f i e l d s a r e n o t c u r r e n t l y s u p p o r t e d \. O n l y p r i v a t e m e t h o d s a r e s u p p o r t e d \. /
614- ) ;
615- } ) ;
616-
617- test ( 'private field alongside private method throws unsupported error' , ( ) => {
618- const source = `
619- import { LightningElement } from 'lwc';
620- export default class Test extends LightningElement {
621- #count = 0;
622- #increment() {
623- this.#count++;
624- }
625- }
626- ` ;
627-
628- expect ( ( ) => transformWithFullPipeline ( source ) ) . toThrowError (
629- / P r i v a t e f i e l d s a r e n o t c u r r e n t l y s u p p o r t e d /
630- ) ;
631- } ) ;
632-
633412 test ( 'private method call sites do not leak prefixed names after round-trip' , ( ) => {
634413 const source = `
635414 import { LightningElement } from 'lwc';
@@ -648,19 +427,6 @@ describe('private method transform validation', () => {
648427 expect ( code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
649428 } ) ;
650429
651- test ( 'private field with initializer throws unsupported error' , ( ) => {
652- const source = `
653- import { LightningElement } from 'lwc';
654- export default class Test extends LightningElement {
655- #state = { ready: false };
656- }
657- ` ;
658-
659- expect ( ( ) => transformWithFullPipeline ( source ) ) . toThrowError (
660- / P r i v a t e f i e l d s a r e n o t c u r r e n t l y s u p p o r t e d /
661- ) ;
662- } ) ;
663-
664430 test ( 'forward-only output transforms call sites to prefixed names' , ( ) => {
665431 const source = `
666432 import { LightningElement } from 'lwc';
@@ -726,50 +492,6 @@ describe('private method transform validation', () => {
726492 expect ( privateMatches ) . toHaveLength ( 4 ) ;
727493 } ) ;
728494
729- test ( 'self-referencing private method round-trips' , ( ) => {
730- const source = `
731- import { LightningElement } from 'lwc';
732- export default class Test extends LightningElement {
733- #recursive(n) {
734- if (n <= 0) return 0;
735- return n + this.#recursive(n - 1);
736- }
737- }
738- ` ;
739-
740- const result = transformForwardOnly ( source ) ;
741- const code = result . code ! ;
742- expect ( code ) . toContain ( 'this.__lwc_component_class_internal_private_recursive(n - 1)' ) ;
743-
744- const roundTrip = transformWithFullPipeline ( source ) ;
745- expect ( roundTrip . code ) . toContain ( 'this.#recursive(n - 1)' ) ;
746- expect ( roundTrip . code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
747- } ) ;
748-
749- test ( 'private method reference without call round-trips' , ( ) => {
750- const source = `
751- import { LightningElement } from 'lwc';
752- export default class Test extends LightningElement {
753- #handler() { return 42; }
754- connectedCallback() {
755- const fn = this.#handler;
756- setTimeout(this.#handler, 100);
757- }
758- }
759- ` ;
760-
761- const result = transformForwardOnly ( source ) ;
762- const code = result . code ! ;
763- expect ( code ) . toContain ( 'this.__lwc_component_class_internal_private_handler;' ) ;
764- expect ( code ) . toContain ( 'this.__lwc_component_class_internal_private_handler, 100' ) ;
765- expect ( code ) . not . toContain ( 'this.#handler' ) ;
766-
767- const roundTrip = transformWithFullPipeline ( source ) ;
768- expect ( roundTrip . code ) . toContain ( 'this.#handler;' ) ;
769- expect ( roundTrip . code ) . toContain ( 'this.#handler, 100' ) ;
770- expect ( roundTrip . code ) . not . toContain ( '__lwc_component_class_internal_private_' ) ;
771- } ) ;
772-
773495 test ( 'cross-method private call sites in forward-only output' , ( ) => {
774496 const source = `
775497 import { LightningElement } from 'lwc';
0 commit comments