@@ -3,15 +3,15 @@ import path from 'path';
33import resolveFrom from 'resolve-from' ;
44import resolveGlobal from 'resolve-global' ;
55import { ParsedCommandLine } from 'typescript-to-lua' ;
6- import * as ts_module from 'typescript/lib/tsserverlibrary' ;
6+ import * as tsserverlibrary from 'typescript/lib/tsserverlibrary' ;
77
88const pluginMarker = Symbol ( 'pluginMarker' ) ;
99class TSTLPlugin {
1010 constructor (
11- private ts : typeof ts_module ,
12- private languageService : ts_module . LanguageService ,
13- private project : ts_module . server . Project ,
14- private serverHost : ts_module . server . ServerHost ,
11+ private readonly ts : typeof tsserverlibrary ,
12+ private readonly languageService : tsserverlibrary . LanguageService ,
13+ private readonly project : tsserverlibrary . server . Project ,
14+ private readonly serverHost : tsserverlibrary . server . ServerHost ,
1515 ) { }
1616
1717 private log ( message : string ) {
@@ -44,6 +44,7 @@ class TSTLPlugin {
4444 'typescript-to-lua' ;
4545
4646 this . log ( `Loading typescript-to-lua from "${ resolved } "` ) ;
47+ // eslint-disable-next-line @typescript-eslint/no-require-imports
4748 this . _tstl = require ( resolved ) ;
4849 }
4950
@@ -54,7 +55,7 @@ class TSTLPlugin {
5455 this . log ( 'Wrapping language service' ) ;
5556 this . update ( ) ;
5657
57- const intercept : Partial < ts_module . LanguageService > = Object . create ( null ) ;
58+ const intercept : Partial < tsserverlibrary . LanguageService > = Object . create ( null ) ;
5859 ( intercept as any ) [ pluginMarker ] = this ;
5960 intercept . getSemanticDiagnostics = this . getSemanticDiagnostics . bind ( this ) ;
6061 return new Proxy ( this . languageService , {
@@ -75,37 +76,40 @@ class TSTLPlugin {
7576 return diagnostics ;
7677 }
7778
78- private getTstlDiagnostics ( program : ts_module . Program , sourceFile : ts_module . SourceFile ) {
79+ private getTstlDiagnostics (
80+ program : tsserverlibrary . Program ,
81+ sourceFile : tsserverlibrary . SourceFile ,
82+ ) {
7983 if ( this . parsedCommandLine != null && this . parsedCommandLine . raw . tstl != null ) {
8084 Object . assign ( program . getCompilerOptions ( ) , this . parsedCommandLine . options ) ;
8185
8286 const transformer = new this . tstl . LuaTransformer ( program ) ;
8387 try {
8488 transformer . transformSourceFile ( sourceFile ) ;
85- } catch ( err ) {
86- if ( err instanceof this . tstl . TranspileError ) {
87- const diagnostic : ts_module . Diagnostic = {
89+ } catch ( error ) {
90+ if ( error instanceof this . tstl . TranspileError ) {
91+ const diagnostic : tsserverlibrary . Diagnostic = {
8892 category : this . ts . DiagnosticCategory . Error ,
8993 code : 0 ,
90- file : err . node . getSourceFile ( ) ,
91- start : err . node . getStart ( ) ,
92- length : err . node . getWidth ( ) ,
93- messageText : err . message ,
94+ file : error . node . getSourceFile ( ) ,
95+ start : error . node . getStart ( ) ,
96+ length : error . node . getWidth ( ) ,
97+ messageText : error . message ,
9498 source : 'typescript-to-lua' ,
9599 } ;
96100
97101 return [ diagnostic ] ;
98102 }
99103
100- this . log ( `Error during transpilation: ${ err . stack } ` ) ;
104+ this . log ( `Error during transpilation: ${ error . stack } ` ) ;
101105 }
102106 }
103107
104108 return [ ] ;
105109 }
106110}
107111
108- const init : ts_module . server . PluginModuleFactory = ( { typescript } ) => {
112+ const init : tsserverlibrary . server . PluginModuleFactory = ( { typescript } ) => {
109113 mockRequire ( 'typescript' , typescript ) ;
110114
111115 return {
0 commit comments