@@ -80,27 +80,19 @@ class TSTLPlugin {
8080 program : tsserverlibrary . Program ,
8181 sourceFile : tsserverlibrary . SourceFile ,
8282 ) {
83- if ( this . parsedCommandLine != null && this . parsedCommandLine . raw . tstl != null ) {
84- Object . assign ( program . getCompilerOptions ( ) , this . parsedCommandLine . options ) ;
83+ if ( this . parsedCommandLine ?. raw . tstl != null ) {
84+ const programOptions = program . getCompilerOptions ( ) ;
85+ Object . assign ( programOptions , this . parsedCommandLine . options ) ;
86+ programOptions . noEmit = true ;
87+ programOptions . noEmitOnError = false ;
88+ programOptions . declaration = false ;
89+ programOptions . declarationMap = false ;
90+ programOptions . emitDeclarationOnly = false ;
8591
86- const transformer = new this . tstl . LuaTransformer ( program ) ;
8792 try {
88- transformer . transformSourceFile ( sourceFile ) ;
93+ const { diagnostics } = this . tstl . transpile ( { program, sourceFiles : [ sourceFile ] } ) ;
94+ return diagnostics ;
8995 } catch ( error ) {
90- if ( error instanceof this . tstl . TranspileError ) {
91- const diagnostic : tsserverlibrary . Diagnostic = {
92- category : this . ts . DiagnosticCategory . Error ,
93- code : 0 ,
94- file : error . node . getSourceFile ( ) ,
95- start : error . node . getStart ( ) ,
96- length : error . node . getWidth ( ) ,
97- messageText : error . message ,
98- source : 'typescript-to-lua' ,
99- } ;
100-
101- return [ diagnostic ] ;
102- }
103-
10496 this . log ( `Error during transpilation: ${ error . stack } ` ) ;
10597 }
10698 }
0 commit comments