-
Notifications
You must be signed in to change notification settings - Fork 30.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[typescript-language-features] Update importModuleSpecifierPreference values #110536
[typescript-language-features] Update importModuleSpecifierPreference values #110536
Conversation
@@ -561,7 +561,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, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by fix now that the API is updated
"typescript.preferences.importModuleSpecifier.shortest": "Prefers using a non-relative import only if one is available that has fewer path segments than a relative import.", | ||
"typescript.preferences.importModuleSpecifier.relative": "Prefers using a relative path to the imported file location.", | ||
"typescript.preferences.importModuleSpecifier.nonRelative": "Prefers using a non-relative import based on the `baseUrl` or `paths` configured in your `jsconfig.json` / `tsconfig.json`.", | ||
"typescript.preferences.importModuleSpecifier.projectRelative": "Prefers using a non-relative import only if the relative import path would leave the package or project directory.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/cc @DanielRosenwasser on the copy update; I know we’ve talked about these before
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also sort of considered adding “Useful for monorepos.” at the end of this one; do you think that would be worthwhile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe instead of "Prefers using" you could switch to "Prefer a"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Useful for monorepos" might be helpful, but I feel like maybe this should be the new default?
How does it know when you've "left' a package? And how surprising is it when you've left a "project directory"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also suspect this might be a better default, but we normally try not to shove unproven changes to defaults on people 🤷.
The implementation details are in microsoft/TypeScript#40637. Briefly, this setting will try to use a non-relative path if the nearest ancestor package.json of the importing file and the nearest ancestor package.json of the imported file are not the same, or if the imported file is outside the directory of the imported file’s tsconfig.json.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll merge once Daniel provides feedback and you tell me it's ready
"typescript.preferences.importModuleSpecifier.shortest": "Prefers using a non-relative import only if one is available that has fewer path segments than a relative import.", | ||
"typescript.preferences.importModuleSpecifier.relative": "Prefers using a relative path to the imported file location.", | ||
"typescript.preferences.importModuleSpecifier.nonRelative": "Prefers using a non-relative import based on the `baseUrl` or `paths` configured in your `jsconfig.json` / `tsconfig.json`.", | ||
"typescript.preferences.importModuleSpecifier.projectRelative": "Prefers using a non-relative import only if the relative import path would leave the package or project directory.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If projectRelative
is a new setting, could you also note which TS version is required to use it?
@mjbvz ready to merge, thanks! |
Thanks! |
… values (#110536) * Update importModuleSpecifierPreference values * -using * Add minimum version message
Counterpart of microsoft/TypeScript#40637.