@@ -167,6 +167,20 @@ export interface LSSvelteConfig {
167
167
} ;
168
168
}
169
169
170
+ /**
171
+ * A subset of the JS/TS VS Code settings which
172
+ * are transformed to ts.UserPreferences.
173
+ * It may not be available in other IDEs, that's why the keys are optional.
174
+ */
175
+ export interface TSUserConfig {
176
+ preferences ?: TsUserPreferencesConfig ;
177
+ suggest ?: TSSuggestConfig ;
178
+ }
179
+
180
+ /**
181
+ * A subset of the JS/TS VS Code settings which
182
+ * are transformed to ts.UserPreferences.
183
+ */
170
184
export interface TsUserPreferencesConfig {
171
185
importModuleSpecifier : UserPreferences [ 'importModuleSpecifierPreference' ] ;
172
186
importModuleSpecifierEnding : UserPreferences [ 'importModuleSpecifierEnding' ] ;
@@ -177,6 +191,14 @@ export interface TsUserPreferencesConfig {
177
191
includePackageJsonAutoImports ?: UserPreferences [ 'includePackageJsonAutoImports' ] ;
178
192
}
179
193
194
+ /**
195
+ * A subset of the JS/TS VS Code settings which
196
+ * are transformed to ts.UserPreferences.
197
+ */
198
+ export interface TSSuggestConfig {
199
+ autoImports : UserPreferences [ 'includeCompletionsForModuleExports' ] ;
200
+ }
201
+
180
202
export type TsUserConfigLang = 'typescript' | 'javascript' ;
181
203
182
204
type DeepPartial < T > = T extends CompilerWarningsSettings
@@ -189,8 +211,12 @@ export class LSConfigManager {
189
211
private config : LSConfig = defaultLSConfig ;
190
212
private listeners : Array < ( config : LSConfigManager ) => void > = [ ] ;
191
213
private tsUserPreferences : Record < TsUserConfigLang , UserPreferences > = {
192
- typescript : { } ,
193
- javascript : { }
214
+ typescript : {
215
+ includeCompletionsForModuleExports : true
216
+ } ,
217
+ javascript : {
218
+ includeCompletionsForModuleExports : true
219
+ }
194
220
} ;
195
221
private prettierConfig : any = { } ;
196
222
private emmetConfig : EmmetConfiguration = { } ;
@@ -258,28 +284,23 @@ export class LSConfigManager {
258
284
return this . prettierConfig ;
259
285
}
260
286
261
- updateTsJsUserPreferences (
262
- config : Record <
263
- TsUserConfigLang ,
264
- {
265
- preferences : TsUserPreferencesConfig ;
266
- }
267
- >
268
- ) : void {
287
+ updateTsJsUserPreferences ( config : Record < TsUserConfigLang , TSUserConfig > ) : void {
269
288
( [ 'typescript' , 'javascript' ] as const ) . forEach ( ( lang ) => {
270
- if ( config [ lang ] ?. preferences ) {
271
- this . _updateTsUserPreferences ( lang , config [ lang ] . preferences ) ;
289
+ if ( config [ lang ] ) {
290
+ this . _updateTsUserPreferences ( lang , config [ lang ] ) ;
272
291
}
273
292
} ) ;
274
293
}
275
294
276
- private _updateTsUserPreferences ( lang : TsUserConfigLang , config : TsUserPreferencesConfig ) {
277
- this . tsUserPreferences [ lang ] = Object . assign ( this . tsUserPreferences [ lang ] , {
278
- importModuleSpecifierPreference : config . importModuleSpecifier ,
279
- importModuleSpecifierEnding : config . importModuleSpecifierEnding ,
280
- includePackageJsonAutoImports : config . includePackageJsonAutoImports ,
281
- quotePreference : config . quoteStyle
282
- } as UserPreferences ) ;
295
+ private _updateTsUserPreferences ( lang : TsUserConfigLang , config : TSUserConfig ) {
296
+ this . tsUserPreferences [ lang ] = {
297
+ ...this . tsUserPreferences [ lang ] ,
298
+ importModuleSpecifierPreference : config . preferences ?. importModuleSpecifier ,
299
+ importModuleSpecifierEnding : config . preferences ?. importModuleSpecifierEnding ,
300
+ includePackageJsonAutoImports : config . preferences ?. includePackageJsonAutoImports ,
301
+ quotePreference : config . preferences ?. quoteStyle ,
302
+ includeCompletionsForModuleExports : config . suggest ?. autoImports ?? true
303
+ } ;
283
304
}
284
305
285
306
getTsUserPreferences ( lang : TsUserConfigLang ) {
0 commit comments