@@ -80,27 +80,19 @@ class TSTLPlugin {
80
80
program : tsserverlibrary . Program ,
81
81
sourceFile : tsserverlibrary . SourceFile ,
82
82
) {
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 ;
85
91
86
- const transformer = new this . tstl . LuaTransformer ( program ) ;
87
92
try {
88
- transformer . transformSourceFile ( sourceFile ) ;
93
+ const { diagnostics } = this . tstl . transpile ( { program, sourceFiles : [ sourceFile ] } ) ;
94
+ return diagnostics ;
89
95
} 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
-
104
96
this . log ( `Error during transpilation: ${ error . stack } ` ) ;
105
97
}
106
98
}
0 commit comments