feat: update preferences.importModuleSpecifier (#295)

https://github.com/microsoft/vscode/pull/110536
This commit is contained in:
Heyward Fann 2021-06-07 11:26:52 +08:00 committed by GitHub
parent 8826e273b5
commit fd957b20f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 8 deletions

View file

@ -277,12 +277,19 @@
},
"typescript.preferences.importModuleSpecifier": {
"type": "string",
"default": "auto",
"default": "shortest",
"description": "Preferred path style for auto imports.",
"enumDescriptions": [
"Prefers a non-relative import only if one is available that has fewer path segments than a relative import",
"Prefers a relative path to the imported file location",
"Prefers a non-relative import based on the `baseUrl` or `paths` configured in your `jsconfig.json` / `tsconfig.json`.",
"Prefers a non-relative import only if the relative import path would leave the package or project directory. Requires using TypeScript 4.2+ in the workspace."
],
"enum": [
"non-relative",
"shortest",
"relative",
"auto"
"non-relative",
"project-relative"
]
},
"typescript.preferences.importModuleSpecifierEnding": {
@ -475,12 +482,19 @@
},
"javascript.preferences.importModuleSpecifier": {
"type": "string",
"default": "auto",
"default": "shortest",
"description": "Preferred path style for auto imports.",
"enumDescriptions": [
"Prefers a non-relative import only if one is available that has fewer path segments than a relative import",
"Prefers a relative path to the imported file location",
"Prefers a non-relative import based on the `baseUrl` or `paths` configured in your `jsconfig.json` / `tsconfig.json`.",
"Prefers a non-relative import only if the relative import path would leave the package or project directory. Requires using TypeScript 4.2+ in the workspace."
],
"enum": [
"auto",
"shortest",
"relative",
"non-relative",
"relative"
"project-relative"
]
},
"javascript.preferences.importModuleSpecifierEnding": {

View file

@ -196,17 +196,19 @@ export default class FileConfigurationManager {
}
}
type ModuleImportType = 'relative' | 'non-relative' | 'auto'
type ModuleImportType = 'shortest' | 'project-relative' | 'relative' | 'non-relative'
function getImportModuleSpecifier(config: WorkspaceConfiguration): ModuleImportType {
let val = config.get('importModuleSpecifier')
switch (val) {
case 'project-relative':
return 'project-relative'
case 'relative':
return 'relative'
case 'non-relative':
return 'non-relative'
default:
return 'auto'
return undefined
}
}