@@ -18,6 +18,15 @@ function existsSync(filepath: string) {
18
18
}
19
19
}
20
20
21
+ interface IConfig {
22
+ enable : boolean ;
23
+ dtsFilepath ?: string ;
24
+ }
25
+
26
+ let config : IConfig = {
27
+ enable : true
28
+ } ;
29
+
21
30
module . exports = function init ( {
22
31
typescript
23
32
} : {
@@ -65,6 +74,15 @@ module.exports = function init({
65
74
reusedNames ?: string [ ] ,
66
75
redirectedReference ?: ts_module . ResolvedProjectReference
67
76
) => {
77
+ if ( ! config . enable ) {
78
+ return resolveModuleNames (
79
+ moduleNames ,
80
+ containingFile ,
81
+ reusedNames ,
82
+ redirectedReference ,
83
+ { }
84
+ ) ;
85
+ }
68
86
moduleNames = moduleNames
69
87
. map ( stripExtNameDotTs )
70
88
. map ( convertRemoteToLocalCache ) ;
@@ -81,6 +99,10 @@ module.exports = function init({
81
99
info . languageServiceHost . getCompilationSettings = ( ) => {
82
100
const projectConfig = getCompilationSettings ( ) ;
83
101
102
+ if ( ! config . enable ) {
103
+ return projectConfig ;
104
+ }
105
+
84
106
// Solve the problem that `import.meta.url` is not parsed correctly
85
107
const mustOverwriteOptions : ts_module . CompilerOptions = {
86
108
module : OPTIONS . module ,
@@ -101,6 +123,10 @@ module.exports = function init({
101
123
info . languageServiceHost . getScriptFileNames = ( ) => {
102
124
const scriptFileNames = getScriptFileNames ( ) ;
103
125
126
+ if ( ! config . enable ) {
127
+ return scriptFileNames ;
128
+ }
129
+
104
130
const denoDtsPath = getDtsPathForVscode ( info ) || getGlobalDtsPath ( ) ;
105
131
106
132
if ( denoDtsPath ) {
@@ -131,6 +157,10 @@ module.exports = function init({
131
157
preferences
132
158
) ;
133
159
160
+ if ( ! config . enable ) {
161
+ return details ;
162
+ }
163
+
134
164
if ( details ) {
135
165
if ( details . codeActions && details . codeActions . length ) {
136
166
for ( const ca of details . codeActions ) {
@@ -154,8 +184,9 @@ module.exports = function init({
154
184
return info . languageService ;
155
185
} ,
156
186
157
- onConfigurationChanged ( config : any ) {
158
- logger . info ( `onConfigurationChanged: ${ JSON . stringify ( config ) } ` ) ;
187
+ onConfigurationChanged ( c : IConfig ) {
188
+ config = merge ( config , c ) ;
189
+ logger . info ( `onConfigurationChanged: ${ JSON . stringify ( c ) } ` ) ;
159
190
}
160
191
} ;
161
192
} ;
0 commit comments