Skip to content

Commit

Permalink
[typescript-language-features] Update importModuleSpecifierPreference…
Browse files Browse the repository at this point in the history
… values (#110536)

* Update importModuleSpecifierPreference values

* -using

* Add minimum version message
  • Loading branch information
andrewbranch authored and meganrogge committed Nov 18, 2020
1 parent 5a08da6 commit 58525be
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 14 deletions.
24 changes: 14 additions & 10 deletions extensions/typescript-language-features/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -660,32 +660,36 @@
"javascript.preferences.importModuleSpecifier": {
"type": "string",
"enum": [
"auto",
"shortest",
"relative",
"non-relative"
"non-relative",
"project-relative"
],
"markdownEnumDescriptions": [
"%typescript.preferences.importModuleSpecifier.auto%",
"%typescript.preferences.importModuleSpecifier.shortest%",
"%typescript.preferences.importModuleSpecifier.relative%",
"%typescript.preferences.importModuleSpecifier.nonRelative%"
"%typescript.preferences.importModuleSpecifier.nonRelative%",
"%typescript.preferences.importModuleSpecifier.projectRelative%"
],
"default": "auto",
"default": "shortest",
"description": "%typescript.preferences.importModuleSpecifier%",
"scope": "resource"
},
"typescript.preferences.importModuleSpecifier": {
"type": "string",
"enum": [
"auto",
"shortest",
"relative",
"non-relative"
"non-relative",
"project-relative"
],
"markdownEnumDescriptions": [
"%typescript.preferences.importModuleSpecifier.auto%",
"%typescript.preferences.importModuleSpecifier.shortest%",
"%typescript.preferences.importModuleSpecifier.relative%",
"%typescript.preferences.importModuleSpecifier.nonRelative%"
"%typescript.preferences.importModuleSpecifier.nonRelative%",
"%typescript.preferences.importModuleSpecifier.projectRelative%"
],
"default": "auto",
"default": "shortest",
"description": "%typescript.preferences.importModuleSpecifier%",
"scope": "resource"
},
Expand Down
7 changes: 4 additions & 3 deletions extensions/typescript-language-features/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,10 @@
"typescript.suggestionActions.enabled": "Enable/disable suggestion diagnostics for TypeScript files in the editor.",
"typescript.preferences.quoteStyle": "Preferred quote style to use for quick fixes: `single` quotes, `double` quotes, or `auto` infer quote type from existing imports.",
"typescript.preferences.importModuleSpecifier": "Preferred path style for auto imports.",
"typescript.preferences.importModuleSpecifier.auto": "Automatically select import path style. Prefers using a relative import if `baseUrl` is configured and the relative path has fewer segments than the non-relative import.",
"typescript.preferences.importModuleSpecifier.relative": "Relative to the file location.",
"typescript.preferences.importModuleSpecifier.nonRelative": "Based on the `baseUrl` configured in your `jsconfig.json` / `tsconfig.json`.",
"typescript.preferences.importModuleSpecifier.shortest": "Prefers a non-relative import only if one is available that has fewer path segments than a relative import.",
"typescript.preferences.importModuleSpecifier.relative": "Prefers a relative path to the imported file location.",
"typescript.preferences.importModuleSpecifier.nonRelative": "Prefers a non-relative import based on the `baseUrl` or `paths` configured in your `jsconfig.json` / `tsconfig.json`.",
"typescript.preferences.importModuleSpecifier.projectRelative": "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.",
"typescript.preferences.importModuleSpecifierEnding": "Preferred path ending for auto imports.",
"typescript.preferences.importModuleSpecifierEnding.auto": "Use project settings to select a default.",
"typescript.preferences.importModuleSpecifierEnding.minimal": "Shorten `./component/index.js` to `./component`.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider<
type: response?.type ?? 'unknown',
count: response?.type === 'response' && response.body ? response.body.entries.length : 0,
updateGraphDurationMs: response?.type === 'response' ? response.performanceData?.updateGraphDurationMs : undefined,
createAutoImportProviderProgramDurationMs: response?.type === 'response' ? (response.performanceData as Proto.PerformanceData & { createAutoImportProviderProgramDurationMs?: number })?.createAutoImportProviderProgramDurationMs : undefined,
createAutoImportProviderProgramDurationMs: response?.type === 'response' ? response.performanceData?.createAutoImportProviderProgramDurationMs : undefined,
includesPackageJsonImport: includesPackageJsonImport ? 'true' : undefined,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export default class FileConfigurationManager extends Disposable {

const preferences: Proto.UserPreferences = {
quotePreference: this.getQuoteStylePreference(preferencesConfig),
// @ts-expect-error until TypeScript 4.2 API
importModuleSpecifierPreference: getImportModuleSpecifierPreference(preferencesConfig),
importModuleSpecifierEnding: getImportModuleSpecifierEndingPreference(preferencesConfig),
allowTextChangesInNewFiles: document.uri.scheme === fileSchemes.file,
Expand All @@ -198,6 +199,7 @@ export default class FileConfigurationManager extends Disposable {

function getImportModuleSpecifierPreference(config: vscode.WorkspaceConfiguration) {
switch (config.get<string>('importModuleSpecifier')) {
case 'project-relative': return 'project-relative';
case 'relative': return 'relative';
case 'non-relative': return 'non-relative';
default: return undefined;
Expand Down

0 comments on commit 58525be

Please sign in to comment.