Repository navigation
Conversation
The TypeScript service only read the deprecated per-language `typescript.*` / `javascript.*` settings, so a Vue `<script>` block ignored the unified `js/ts.*` settings that VS Code's built-in TS extension prefers. This affected formatting, user preferences (`autoImportSpecifierExcludeRegexes` among them), suggestions, validation and auto-closing tags. Add `createUnifiedConfig()`, which resolves both the unified `js/ts` section and the language-specific section once and reads a setting with the unified value taking precedence. Wire every language-specific read in the package through it, so the fallback applies to all JS/TS settings rather than formats only. VS Code can tell "unset" from "explicitly set to the default" because it has `WorkspaceConfiguration.inspect()`. A language server cannot: `workspace/configuration` returns the resolved value with the registered default included. The helper therefore treats a unified value equal to its registered default as unset and keeps the defaults in one table, kept in sync with VS Code's `typescript-language-features` package.json. Closes vuejs/language-tools#6150
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The TypeScript service only read the deprecated per-language settings (
typescript.*/javascript.*), so an embedded<script>block ignored the unifiedjs/ts.*settings that VS Code's built-in TypeScript extension prefers.The reported case is formatting (vuejs/language-tools#6150), but the same gap affects every setting the package reads. @HiDeoo found it while debugging
js/ts.preferences.autoImportSpecifierExcludeRegexesin an Astro project, where thetypescript.preferences.*spelling worked and the unified one did not.This supersedes #126, which only covered
js/ts.format.*.Change
Add
createUnifiedConfig(), which resolves the unifiedjs/tssection and the language-specific section once, then reads each setting with the unified value taking precedence:Every language-specific read in the package now goes through it:
js/ts.format.*(18 keys, incl.indentSwitchCase)js/ts.preferences.*js/ts.suggest.*js/ts.validate.enabledjs/ts.autoClosingTags.enabledjs/ts.inlayHints.*getUserPreferences()is included, which resolves the review comment.renameShorthandPropertiesandunstablehave no unified counterpart and keep reading the language-specific section.Why the default table
VS Code's built-in extension decides with
WorkspaceConfiguration.inspect()— it knows whether a unified setting was actually modified. A language server cannot:workspace/configurationreturns the resolved value with the registered default already merged in, so an unset setting is indistinguishable from one set to its default.The helper therefore treats a unified value equal to its registered default as unset, and keeps every default in one table (
unifiedDefaults) that mirrorscontributes.configurationof VS Code'stypescript-language-featurespackage.json. This is the best available approach: the hardcoded-default comparison is only a heuristic, and a table is the smallest version of that heuristic — one line per changed default instead of 40 scattered?? defaultsites.I verified the table mechanically against VS Code's current
package.json: all 50 keys match, and every relevantjs/ts.*setting that the service reads is covered.Remaining limitation, unchanged in kind from #126: explicitly setting a unified key to its exact default while also setting the deprecated counterpart to a different value resolves to the deprecated value. VS Code would take the unified default. This needs
inspect()over the wire to fix.Options considered:
inspect(). Only correct fix. Needs aLanguageServiceEnvironmentAPI plus a client-side handler in@volar/vscode/vuejs/language-tools, so it is out of scope here. If it lands,createUnifiedConfigis the single place to switch over.typescript.format.*setting for users who only configured those.Separately,
workspace/configurationis requested without a document scope, so language-scoped overrides such as"[typescript]": { "js/ts.format.semicolons": "insert" }are still not visible to the server. That is a pre-existing limitation of the host request, not of this change.One pre-existing read is deliberately left alone: the auto-import cache's
setPreferencesstill readstypescript.preferences. It applies to the whole language service rather than a document, so there is no language section to fall back to; moving it tojs/ts.preferenceswould need a separate decision about which section it should use. TheincludeInlayParameterNameHintsmapping also keeps its current behavior, where'none'maps toundefined.Test plan
pnpm run build,pnpm run test,pnpm run lint,dprint checkgetUnifiedConfig,getFormatCodeSettings,getUserPreferences, covering unified precedence, fallback when the unified value equals its default, language-specific fallback, a host that returns only explicitly-set values (@volar/kit), defaults, and pattern normalization.Closes vuejs/language-tools#6150
Supersedes #126