@@ -89,12 +89,15 @@ export function moveFieldInitializersToConstructor(): unknown {
8989
9090 const ctorBody = ctor . body ! . body as Stmt [ ] ;
9191
92- let insertAt = 0 ;
93- for ( let i = 0 ; i < ctorBody . length ; i += 1 ) {
94- const stmt = ctorBody [ i ] ;
95- const isSuperCall = stmt . type === 'ExpressionStatement'
92+ const superCallIdx = ctorBody . findIndex (
93+ ( stmt ) => stmt . type === 'ExpressionStatement'
9694 && stmt . expression ?. type === 'CallExpression'
97- && stmt . expression . callee ?. type === 'Super' ;
95+ && stmt . expression . callee ?. type === 'Super' ,
96+ ) ;
97+
98+ let insertAt = superCallIdx !== - 1 ? superCallIdx + 1 : 0 ;
99+ while ( insertAt < ctorBody . length ) {
100+ const stmt = ctorBody [ insertAt ] ;
98101 const isParamPropertyAssignment = stmt . type === 'ExpressionStatement'
99102 && stmt . expression ?. type === 'AssignmentExpression'
100103 && stmt . expression . operator === '='
@@ -104,7 +107,8 @@ export function moveFieldInitializersToConstructor(): unknown {
104107 && stmt . expression . left . property ?. name === stmt . expression . right . name
105108 && paramNames . has ( stmt . expression . right . name ! ) ;
106109
107- if ( isSuperCall || isParamPropertyAssignment ) insertAt = i + 1 ;
110+ if ( ! isParamPropertyAssignment ) break ;
111+ insertAt += 1 ;
108112 }
109113
110114 ctorBody . splice ( insertAt , 0 , ...( assignments as Stmt [ ] ) ) ;
0 commit comments