Merge pull request #226202 from andrewbranch/autoImportSpecifierExcludeRegexes

[typescript-language-features] Add autoImportSpecifierExcludeRegexes preference
This commit is contained in:
Matt Bierner
2024-08-23 13:23:49 -07:00
committed by GitHub
3 changed files with 19 additions and 0 deletions

View File

@@ -1030,6 +1030,22 @@
"markdownDescription": "%typescript.preferences.autoImportFileExcludePatterns%",
"scope": "resource"
},
"typescript.preferences.autoImportSpecifierExcludeRegexes": {
"type": "array",
"items": {
"type": "string"
},
"markdownDescription": "%typescript.preferences.autoImportSpecifierExcludeRegexes%",
"scope": "resource"
},
"javascript.preferences.autoImportSpecifierExcludeRegexes": {
"type": "array",
"items": {
"type": "string"
},
"markdownDescription": "%typescript.preferences.autoImportSpecifierExcludeRegexes%",
"scope": "resource"
},
"typescript.preferences.preferTypeOnlyAutoImports": {
"type": "boolean",
"default": false,

View File

@@ -155,6 +155,7 @@
"typescript.preferences.includePackageJsonAutoImports.on": "Always search dependencies.",
"typescript.preferences.includePackageJsonAutoImports.off": "Never search dependencies.",
"typescript.preferences.autoImportFileExcludePatterns": "Specify glob patterns of files to exclude from auto imports. Relative paths are resolved relative to the workspace root. Patterns are evaluated using tsconfig.json [`exclude`](https://www.typescriptlang.org/tsconfig#exclude) semantics.",
"typescript.preferences.autoImportSpecifierExcludeRegexes": "Specify regular expressions to exclude auto imports with matching import specifiers. Examples:\n\n- `^node:`\n- `lib/internal` (slashes don't need to be escaped...)\n- `/lib\\/internal/i` (...unless including surrounding slashes for `i` or `u` flags)\n- `^lodash$` (only allow subpath imports from lodash)",
"typescript.preferences.preferTypeOnlyAutoImports": "Include the `type` keyword in auto-imports whenever possible. Requires using TypeScript 5.3+ in the workspace.",
"typescript.workspaceSymbols.excludeLibrarySymbols": "Exclude symbols that come from library files in Go to Symbol in Workspace results. Requires using TypeScript 5.3+ in the workspace.",
"typescript.updateImportsOnFileMove.enabled": "Enable/disable automatic updating of import paths when you rename or move a file in VS Code.",

View File

@@ -191,6 +191,8 @@ export default class FileConfigurationManager extends Disposable {
includeCompletionsWithClassMemberSnippets: config.get<boolean>('suggest.classMemberSnippets.enabled', true),
includeCompletionsWithObjectLiteralMethodSnippets: config.get<boolean>('suggest.objectLiteralMethodSnippets.enabled', true),
autoImportFileExcludePatterns: this.getAutoImportFileExcludePatternsPreference(preferencesConfig, vscode.workspace.getWorkspaceFolder(document.uri)?.uri),
// @ts-expect-error until 5.6
autoImportSpecifierExcludeRegexes: preferencesConfig.get<string[]>('autoImportSpecifierExcludeRegexes'),
preferTypeOnlyAutoImports: preferencesConfig.get<boolean>('preferTypeOnlyAutoImports', false),
useLabelDetailsInCompletionEntries: true,
allowIncompleteCompletions: true,