@@ -60,14 +60,14 @@ export class CustomTypeScriptWorker extends TypeScriptWorker {
6060 compilerOptions . luaTarget = tstl . LuaTarget . Lua53 ;
6161 compilerOptions . sourceMap = true ;
6262
63- let ast ! : tstl . File ;
64- let lua ! : string ;
65- let sourceMap ! : string ;
63+ let ast : tstl . File | undefined ;
64+ let lua : string | undefined ;
65+ let sourceMap : string | undefined ;
6666 const { diagnostics } = transpiler . emit ( {
6767 program,
6868 sourceFiles : [ sourceFile ] ,
6969 writeFile ( fileName , data , _writeBOM , _onError , sourceFiles = [ ] ) {
70- if ( ! sourceFiles . includes ( sourceFile ) ) return ;
70+ if ( ! sourceFiles . some ( f => f . fileName === sourceFile . fileName ) ) return ;
7171 if ( fileName . endsWith ( ".lua" ) ) lua = data ;
7272 if ( fileName . endsWith ( ".lua.map" ) ) sourceMap = data ;
7373 } ,
@@ -77,7 +77,7 @@ export class CustomTypeScriptWorker extends TypeScriptWorker {
7777 [ ts . SyntaxKind . SourceFile ] ( node , context ) {
7878 const [ file ] = context . superTransformNode ( node ) as [ tstl . File ] ;
7979
80- if ( node === sourceFile ) {
80+ if ( node . fileName === sourceFile . fileName ) {
8181 ast = file ;
8282 }
8383
@@ -88,6 +88,10 @@ export class CustomTypeScriptWorker extends TypeScriptWorker {
8888 ] ,
8989 } ) ;
9090
91+ if ( ! ast ) throw "Could not get transpiled Lua AST" ;
92+ if ( ! lua ) throw "Could not get transpiled Lua" ;
93+ if ( ! sourceMap ) throw "Could not get tstl source map"
94+
9195 this . lastResult = { diagnostics, ast, lua, sourceMap } ;
9296 return this . lastResult ;
9397 }
0 commit comments