@@ -37,6 +37,7 @@ function getCustomTransformers(
3737}
3838
3939export interface TranspiledFile {
40+ fileName : string ;
4041 luaAst ?: Block ;
4142 lua ?: string ;
4243 sourceMap ?: string ;
@@ -46,7 +47,7 @@ export interface TranspiledFile {
4647
4748export interface TranspileResult {
4849 diagnostics : ts . Diagnostic [ ] ;
49- transpiledFiles : Map < string , TranspiledFile > ;
50+ transpiledFiles : TranspiledFile [ ] ;
5051}
5152
5253export interface TranspileOptions {
@@ -67,12 +68,16 @@ export function transpile({
6768 const options = program . getCompilerOptions ( ) as CompilerOptions ;
6869
6970 const diagnostics : ts . Diagnostic [ ] = [ ] ;
70- const transpiledFiles = new Map < string , TranspiledFile > ( ) ;
71- const updateTranspiledFile = ( filePath : string , file : TranspiledFile ) => {
72- if ( transpiledFiles . has ( filePath ) ) {
73- Object . assign ( transpiledFiles . get ( filePath ) , file ) ;
71+ let transpiledFiles : TranspiledFile [ ] = [ ] ;
72+
73+ // TODO: Included in TS3.5
74+ type Omit < T , K extends keyof T > = Pick < T , Exclude < keyof T , K > > ;
75+ const updateTranspiledFile = ( fileName : string , update : Omit < TranspiledFile , "fileName" > ) => {
76+ const file = transpiledFiles . find ( f => f . fileName === fileName ) ;
77+ if ( file ) {
78+ Object . assign ( file , update ) ;
7479 } else {
75- transpiledFiles . set ( filePath , file ) ;
80+ transpiledFiles . push ( { fileName , ... update } ) ;
7681 }
7782 } ;
7883
@@ -172,7 +177,7 @@ export function transpile({
172177 options . noEmit = oldNoEmit ;
173178
174179 if ( options . noEmit || ( options . noEmitOnError && diagnostics . length > 0 ) ) {
175- transpiledFiles . clear ( ) ;
180+ transpiledFiles = [ ] ;
176181 }
177182
178183 return { diagnostics, transpiledFiles } ;
0 commit comments