Skip to content

fix(typescript): respect unified js/ts.format settings - #126

Open
NamesMT wants to merge 1 commit into
volarjs:masterfrom
NamesMT:fix/read-unified-js-ts-format-settings
Open

NamesMT wants to merge 1 commit into
volarjs:masterfrom
NamesMT:fix/read-unified-js-ts-format-settings

Conversation

@NamesMT

@NamesMT NamesMT commented Sep 13, 2026

Copy link
Copy Markdown

Problem

Volar's TypeScript formatting service only reads the deprecated per-language format settings (typescript.format.* / javascript.format.*) when formatting embedded script blocks. The unified js/ts.format.* settings are ignored, so a Vue <script setup lang="ts"> block formats differently from a regular .ts file when only the unified settings are configured.

Closes vuejs/language-tools#6150

What VS Code does

VS Code's built-in TypeScript extension reads the unified js/ts.format.* settings first and only falls back to the language-specific sections (typescript.format.* / javascript.format.*) when the unified value is not configured — see readUnifiedConfig.

Change

getFormatCodeSettings now also reads js/ts.format and gives those values precedence over the language-specific sections, while still falling back to the deprecated settings.

One caveat worth noting for reviewers: LanguageServiceEnvironment.getConfiguration only returns resolved values (including registered defaults), with no inspect()-style "was this explicitly set" signal. So we approximate the unified-wins fallback by preferring a unified value only when it differs from its registered default. This behaves identically to VS Code in practice; the only theoretical divergence is explicitly setting a unified key to its exact default while also setting the deprecated counterpart to a different value.

Test plan

Added unit tests covering:

  • unified js/ts.format.* settings are honored
  • fallback to language-specific typescript.format.* / javascript.format.*
  • unified takes precedence when both are set
  • defaults are used when nothing is configured

…s/language-tools)

volar-service-typescript only read the deprecated per-language
`typescript.format.*` / `javascript.format.*` settings when formatting
embedded script blocks, ignoring the unified `js/ts.format.*` settings.
VS Code's built-in TS extension reads `js/ts.format.*` first and only
falls back to the language-specific sections when the unified value is
not configured. Mirror that behavior so Vue script blocks format
consistently with regular TS/JS files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unified js/ts.format settings are ignored in Vue script blocks

1 participant