@@ -3,15 +3,15 @@ import path from 'path';
3
3
import resolveFrom from 'resolve-from' ;
4
4
import resolveGlobal from 'resolve-global' ;
5
5
import { ParsedCommandLine } from 'typescript-to-lua' ;
6
- import * as ts_module from 'typescript/lib/tsserverlibrary' ;
6
+ import * as tsserverlibrary from 'typescript/lib/tsserverlibrary' ;
7
7
8
8
const pluginMarker = Symbol ( 'pluginMarker' ) ;
9
9
class TSTLPlugin {
10
10
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 ,
15
15
) { }
16
16
17
17
private log ( message : string ) {
@@ -44,6 +44,7 @@ class TSTLPlugin {
44
44
'typescript-to-lua' ;
45
45
46
46
this . log ( `Loading typescript-to-lua from "${ resolved } "` ) ;
47
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
47
48
this . _tstl = require ( resolved ) ;
48
49
}
49
50
@@ -54,7 +55,7 @@ class TSTLPlugin {
54
55
this . log ( 'Wrapping language service' ) ;
55
56
this . update ( ) ;
56
57
57
- const intercept : Partial < ts_module . LanguageService > = Object . create ( null ) ;
58
+ const intercept : Partial < tsserverlibrary . LanguageService > = Object . create ( null ) ;
58
59
( intercept as any ) [ pluginMarker ] = this ;
59
60
intercept . getSemanticDiagnostics = this . getSemanticDiagnostics . bind ( this ) ;
60
61
return new Proxy ( this . languageService , {
@@ -75,37 +76,40 @@ class TSTLPlugin {
75
76
return diagnostics ;
76
77
}
77
78
78
- private getTstlDiagnostics ( program : ts_module . Program , sourceFile : ts_module . SourceFile ) {
79
+ private getTstlDiagnostics (
80
+ program : tsserverlibrary . Program ,
81
+ sourceFile : tsserverlibrary . SourceFile ,
82
+ ) {
79
83
if ( this . parsedCommandLine != null && this . parsedCommandLine . raw . tstl != null ) {
80
84
Object . assign ( program . getCompilerOptions ( ) , this . parsedCommandLine . options ) ;
81
85
82
86
const transformer = new this . tstl . LuaTransformer ( program ) ;
83
87
try {
84
88
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 = {
88
92
category : this . ts . DiagnosticCategory . Error ,
89
93
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 ,
94
98
source : 'typescript-to-lua' ,
95
99
} ;
96
100
97
101
return [ diagnostic ] ;
98
102
}
99
103
100
- this . log ( `Error during transpilation: ${ err . stack } ` ) ;
104
+ this . log ( `Error during transpilation: ${ error . stack } ` ) ;
101
105
}
102
106
}
103
107
104
108
return [ ] ;
105
109
}
106
110
}
107
111
108
- const init : ts_module . server . PluginModuleFactory = ( { typescript } ) => {
112
+ const init : tsserverlibrary . server . PluginModuleFactory = ( { typescript } ) => {
109
113
mockRequire ( 'typescript' , typescript ) ;
110
114
111
115
return {
0 commit comments