Add setting for package.json auto imports (#103037)
This commit is contained in:
parent
9fe56bdaac
commit
1c8662b8bf
|
@ -686,6 +686,22 @@
|
||||||
"description": "%typescript.preferences.importModuleSpecifierEnding%",
|
"description": "%typescript.preferences.importModuleSpecifierEnding%",
|
||||||
"scope": "resource"
|
"scope": "resource"
|
||||||
},
|
},
|
||||||
|
"typescript.preferences.includePackageJsonAutoImports": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"all",
|
||||||
|
"exclude-dev",
|
||||||
|
"none"
|
||||||
|
],
|
||||||
|
"enumDescriptions": [
|
||||||
|
"%typescript.preferences.includePackageJsonAutoImports.all%",
|
||||||
|
"%typescript.preferences.includePackageJsonAutoImports.excludeDev%",
|
||||||
|
"%typescript.preferences.includePackageJsonAutoImports.none%"
|
||||||
|
],
|
||||||
|
"default": "exclude-dev",
|
||||||
|
"markdownDescription": "%typescript.preferences.includePackageJsonAutoImports%",
|
||||||
|
"scope": "window"
|
||||||
|
},
|
||||||
"javascript.preferences.renameShorthandProperties": {
|
"javascript.preferences.renameShorthandProperties": {
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"default": true,
|
"default": true,
|
||||||
|
|
|
@ -74,8 +74,12 @@
|
||||||
"typescript.preferences.importModuleSpecifierEnding": "Preferred path ending for auto imports.",
|
"typescript.preferences.importModuleSpecifierEnding": "Preferred path ending for auto imports.",
|
||||||
"typescript.preferences.importModuleSpecifierEnding.auto": "Use project settings to select a default.",
|
"typescript.preferences.importModuleSpecifierEnding.auto": "Use project settings to select a default.",
|
||||||
"typescript.preferences.importModuleSpecifierEnding.minimal": "Shorten `./component/index.js` to `./component`.",
|
"typescript.preferences.importModuleSpecifierEnding.minimal": "Shorten `./component/index.js` to `./component`.",
|
||||||
"typescript.preferences.importModuleSpecifierEnding.index": "Shorten `./component/index.js` to `./component/index`",
|
"typescript.preferences.importModuleSpecifierEnding.index": "Shorten `./component/index.js` to `./component/index`.",
|
||||||
"typescript.preferences.importModuleSpecifierEnding.js": "Do not shorten path endings; include the `.js` extension.",
|
"typescript.preferences.importModuleSpecifierEnding.js": "Do not shorten path endings; include the `.js` extension.",
|
||||||
|
"typescript.preferences.includePackageJsonAutoImports": "Enable/disable processing `package.json` dependencies for available auto imports.",
|
||||||
|
"typescript.preferences.includePackageJsonAutoImports.all": "Include all listed dependencies.",
|
||||||
|
"typescript.preferences.includePackageJsonAutoImports.excludeDev": "Exclude devDependencies.",
|
||||||
|
"typescript.preferences.includePackageJsonAutoImports.none": "Disable package.json dependency processing.",
|
||||||
"typescript.updateImportsOnFileMove.enabled": "Enable/disable automatic updating of import paths when you rename or move a file in VS Code. Requires using TypeScript 2.9 or newer in the workspace.",
|
"typescript.updateImportsOnFileMove.enabled": "Enable/disable automatic updating of import paths when you rename or move a file in VS Code. Requires using TypeScript 2.9 or newer in the workspace.",
|
||||||
"typescript.updateImportsOnFileMove.enabled.prompt": "Prompt on each rename.",
|
"typescript.updateImportsOnFileMove.enabled.prompt": "Prompt on each rename.",
|
||||||
"typescript.updateImportsOnFileMove.enabled.always": "Always update paths automatically.",
|
"typescript.updateImportsOnFileMove.enabled.always": "Always update paths automatically.",
|
||||||
|
|
|
@ -526,6 +526,8 @@ export default class TypeScriptServiceClient extends Disposable implements IType
|
||||||
preferences: {
|
preferences: {
|
||||||
providePrefixAndSuffixTextForRename: true,
|
providePrefixAndSuffixTextForRename: true,
|
||||||
allowRenameOfImportPath: true,
|
allowRenameOfImportPath: true,
|
||||||
|
// @ts-expect-error, remove after 4.0 protocol update
|
||||||
|
includePackageJsonAutoImports: this._configuration.includePackageJsonAutoImports,
|
||||||
},
|
},
|
||||||
watchOptions
|
watchOptions
|
||||||
};
|
};
|
||||||
|
|
|
@ -66,6 +66,7 @@ export class TypeScriptServiceConfiguration {
|
||||||
public readonly maxTsServerMemory: number;
|
public readonly maxTsServerMemory: number;
|
||||||
public readonly enablePromptUseWorkspaceTsdk: boolean;
|
public readonly enablePromptUseWorkspaceTsdk: boolean;
|
||||||
public readonly watchOptions: protocol.WatchOptions | undefined;
|
public readonly watchOptions: protocol.WatchOptions | undefined;
|
||||||
|
public readonly includePackageJsonAutoImports: string | undefined;
|
||||||
|
|
||||||
public static loadFromWorkspace(): TypeScriptServiceConfiguration {
|
public static loadFromWorkspace(): TypeScriptServiceConfiguration {
|
||||||
return new TypeScriptServiceConfiguration();
|
return new TypeScriptServiceConfiguration();
|
||||||
|
@ -88,6 +89,7 @@ export class TypeScriptServiceConfiguration {
|
||||||
this.maxTsServerMemory = TypeScriptServiceConfiguration.readMaxTsServerMemory(configuration);
|
this.maxTsServerMemory = TypeScriptServiceConfiguration.readMaxTsServerMemory(configuration);
|
||||||
this.enablePromptUseWorkspaceTsdk = TypeScriptServiceConfiguration.readEnablePromptUseWorkspaceTsdk(configuration);
|
this.enablePromptUseWorkspaceTsdk = TypeScriptServiceConfiguration.readEnablePromptUseWorkspaceTsdk(configuration);
|
||||||
this.watchOptions = TypeScriptServiceConfiguration.readWatchOptions(configuration);
|
this.watchOptions = TypeScriptServiceConfiguration.readWatchOptions(configuration);
|
||||||
|
this.includePackageJsonAutoImports = TypeScriptServiceConfiguration.readIncludePackageJsonAutoImports(configuration);
|
||||||
}
|
}
|
||||||
|
|
||||||
public isEqualTo(other: TypeScriptServiceConfiguration): boolean {
|
public isEqualTo(other: TypeScriptServiceConfiguration): boolean {
|
||||||
|
@ -104,7 +106,8 @@ export class TypeScriptServiceConfiguration {
|
||||||
&& this.enableProjectDiagnostics === other.enableProjectDiagnostics
|
&& this.enableProjectDiagnostics === other.enableProjectDiagnostics
|
||||||
&& this.maxTsServerMemory === other.maxTsServerMemory
|
&& this.maxTsServerMemory === other.maxTsServerMemory
|
||||||
&& objects.equals(this.watchOptions, other.watchOptions)
|
&& objects.equals(this.watchOptions, other.watchOptions)
|
||||||
&& this.enablePromptUseWorkspaceTsdk === other.enablePromptUseWorkspaceTsdk;
|
&& this.enablePromptUseWorkspaceTsdk === other.enablePromptUseWorkspaceTsdk
|
||||||
|
&& this.includePackageJsonAutoImports === other.includePackageJsonAutoImports;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static fixPathPrefixes(inspectValue: string): string {
|
private static fixPathPrefixes(inspectValue: string): string {
|
||||||
|
@ -178,6 +181,10 @@ export class TypeScriptServiceConfiguration {
|
||||||
return configuration.get<protocol.WatchOptions>('typescript.tsserver.watchOptions');
|
return configuration.get<protocol.WatchOptions>('typescript.tsserver.watchOptions');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static readIncludePackageJsonAutoImports(configuration: vscode.WorkspaceConfiguration): string | undefined {
|
||||||
|
return configuration.get<string>('typescript.preferences.includePackageJsonAutoImports');
|
||||||
|
}
|
||||||
|
|
||||||
private static readMaxTsServerMemory(configuration: vscode.WorkspaceConfiguration): number {
|
private static readMaxTsServerMemory(configuration: vscode.WorkspaceConfiguration): number {
|
||||||
const defaultMaxMemory = 3072;
|
const defaultMaxMemory = 3072;
|
||||||
const minimumMaxMemory = 128;
|
const minimumMaxMemory = 128;
|
||||||
|
|
Loading…
Reference in a new issue