File tree Expand file tree Collapse file tree 2 files changed +26
-4
lines changed
src/transformation/visitors/class Expand file tree Collapse file tree 2 files changed +26
-4
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,17 @@ function transformClassLikeDeclaration(
160160 }
161161
162162 // Transform class members
163+
164+ // First transform the methods, in case the static properties call them
165+ for ( const member of classDeclaration . members ) {
166+ if ( ts . isMethodDeclaration ( member ) ) {
167+ // Methods
168+ const statements = transformMethodDeclaration ( context , member , localClassName ) ;
169+ result . push ( ...statements ) ;
170+ }
171+ }
172+
173+ // Then transform the rest
163174 for ( const member of classDeclaration . members ) {
164175 if ( ts . isAccessor ( member ) ) {
165176 // Accessors
@@ -170,10 +181,6 @@ function transformClassLikeDeclaration(
170181 if ( accessorsResult ) {
171182 result . push ( accessorsResult ) ;
172183 }
173- } else if ( ts . isMethodDeclaration ( member ) ) {
174- // Methods
175- const statements = transformMethodDeclaration ( context , member , localClassName ) ;
176- result . push ( ...statements ) ;
177184 } else if ( ts . isPropertyDeclaration ( member ) ) {
178185 // Properties
179186 if ( isStaticNode ( member ) ) {
Original file line number Diff line number Diff line change @@ -818,3 +818,18 @@ test("static initialization block (#1447)", () => {
818818 export const result2 = A.staticProperty3;
819819 ` . expectToMatchJsResult ( ) ;
820820} ) ;
821+
822+ // https://github.com/TypeScriptToLua/TypeScriptToLua/issues/1457
823+ test ( "static member definition order (#1457)" , ( ) => {
824+ util . testFunction `
825+ class A {
826+ static a = A.foo()
827+
828+ static foo(): number {
829+ return 5
830+ }
831+ }
832+
833+ return A.a;
834+ ` . expectToMatchJsResult ( ) ;
835+ } ) ;
You can’t perform that action at this time.
0 commit comments