@@ -60,14 +60,14 @@ export class CustomTypeScriptWorker extends TypeScriptWorker {
60
60
compilerOptions . luaTarget = tstl . LuaTarget . Lua53 ;
61
61
compilerOptions . sourceMap = true ;
62
62
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 ;
66
66
const { diagnostics } = transpiler . emit ( {
67
67
program,
68
68
sourceFiles : [ sourceFile ] ,
69
69
writeFile ( fileName , data , _writeBOM , _onError , sourceFiles = [ ] ) {
70
- if ( ! sourceFiles . includes ( sourceFile ) ) return ;
70
+ if ( ! sourceFiles . some ( f => f . fileName === sourceFile . fileName ) ) return ;
71
71
if ( fileName . endsWith ( ".lua" ) ) lua = data ;
72
72
if ( fileName . endsWith ( ".lua.map" ) ) sourceMap = data ;
73
73
} ,
@@ -77,7 +77,7 @@ export class CustomTypeScriptWorker extends TypeScriptWorker {
77
77
[ ts . SyntaxKind . SourceFile ] ( node , context ) {
78
78
const [ file ] = context . superTransformNode ( node ) as [ tstl . File ] ;
79
79
80
- if ( node === sourceFile ) {
80
+ if ( node . fileName === sourceFile . fileName ) {
81
81
ast = file ;
82
82
}
83
83
@@ -88,6 +88,10 @@ export class CustomTypeScriptWorker extends TypeScriptWorker {
88
88
] ,
89
89
} ) ;
90
90
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
+
91
95
this . lastResult = { diagnostics, ast, lua, sourceMap } ;
92
96
return this . lastResult ;
93
97
}
0 commit comments