@@ -570,6 +570,84 @@ describe('react-native-babel-preset transform snapshots', () => {
570570 expect ( result ) . toContain ( '_classPrivateFieldLooseKey' ) ;
571571 } ) ;
572572
573+ it ( 'transforms class static blocks without unstable_preserveClassPrivate' , ( ) => {
574+ const code = `
575+ class Config {
576+ static value = 0;
577+ static {
578+ Config.value = 2;
579+ }
580+ }
581+ ` ;
582+ const result = transformCode ( code , {
583+ dev : false ,
584+ unstable_transformProfile : 'hermes-stable' ,
585+ } ) ;
586+ expect ( result ) . not . toContain ( 'static {' ) ;
587+ expect ( result ) . toContain ( 'Config.value = 2' ) ;
588+ } ) ;
589+
590+ it ( 'transforms class static blocks when the profile lowers classes' , ( ) => {
591+ const code = `
592+ class Config {
593+ static value = 0;
594+ static {
595+ Config.value = 2;
596+ }
597+ }
598+ ` ;
599+ const result = transformCode ( code , {
600+ dev : false ,
601+ unstable_transformProfile : 'hermes-legacy' ,
602+ customTransformOptions : {
603+ unstable_preserveClassPrivate : true ,
604+ } ,
605+ } ) ;
606+ expect ( result ) . not . toContain ( 'static {' ) ;
607+ expect ( result ) . toContain ( 'Config.value = 2' ) ;
608+ } ) ;
609+
610+ it ( 'transforms class static blocks that use private fields and super' , ( ) => {
611+ const code = `
612+ class Base {
613+ static base = 1;
614+ }
615+ class Config extends Base {
616+ static #secret = 1;
617+ static value = 0;
618+ static {
619+ Config.value = Config.#secret + super.base;
620+ }
621+ }
622+ ` ;
623+ const result = transformCode ( code , {
624+ dev : false ,
625+ unstable_transformProfile : 'hermes-stable' ,
626+ } ) ;
627+ expect ( result ) . not . toContain ( 'static {' ) ;
628+ expect ( result ) . not . toContain ( '#secret' ) ;
629+ } ) ;
630+
631+ it ( 'preserves class static blocks with unstable_preserveClassPrivate' , ( ) => {
632+ const code = `
633+ class Config {
634+ static #secret = 1;
635+ static {
636+ Config.value = Config.#secret;
637+ }
638+ }
639+ ` ;
640+ const result = transformCode ( code , {
641+ dev : false ,
642+ unstable_transformProfile : 'hermes-stable' ,
643+ customTransformOptions : {
644+ unstable_preserveClassPrivate : true ,
645+ } ,
646+ } ) ;
647+ expect ( result ) . toContain ( 'static {' ) ;
648+ expect ( result ) . toContain ( '#secret' ) ;
649+ } ) ;
650+
573651 it ( 'preserves async/await with unstable_preserveAsync' , ( ) => {
574652 const code = `
575653 async function fetchData() {
0 commit comments