File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1132,7 +1132,7 @@ export abstract class LuaTranspiler {
11321132
11331133 public transpileTypeOfExpression ( node : ts . TypeOfExpression ) : string {
11341134 const expression = this . transpileExpression ( node . expression ) ;
1135- return `type(${ expression } )` ;
1135+ return `type(${ expression } ) == "table" and "object" or type( ${ expression } ) ` ;
11361136 }
11371137
11381138 // Transpile a variable statement
Original file line number Diff line number Diff line change @@ -42,15 +42,23 @@ export class OverloadTests {
4242 const lua = util . transpileString ( `return typeof ${ inp } ;` ) ;
4343 const result = util . executeLua ( lua ) ;
4444
45- Expect ( result ) . toBe ( "table " ) ;
45+ Expect ( result ) . toBe ( "object " ) ;
4646 }
4747
4848 @Test ( "typeof class instance" )
4949 public typeofClassInstance ( ) {
5050 const lua = util . transpileString ( `class myClass {} let inst = new myClass(); return typeof inst;` ) ;
5151 const result = util . executeLua ( lua ) ;
5252
53- Expect ( result ) . toBe ( "table" ) ;
53+ Expect ( result ) . toBe ( "object" ) ;
54+ }
55+
56+ @Test ( "typeof function" )
57+ public typeofFunction ( ) {
58+ const lua = util . transpileString ( `return typeof (() => 3);` ) ;
59+ const result = util . executeLua ( lua ) ;
60+
61+ Expect ( result ) . toBe ( "function" ) ;
5462 }
5563
5664 @TestCase ( "null" )
You can’t perform that action at this time.
0 commit comments