Skip to content

fix(builtins): read svelte-i18n params from options.values - #160

Closed
0froq wants to merge 1 commit into
mainfrom
fix/svelte-i18n-params-values
Closed

0froq wants to merge 1 commit into
mainfrom
fix/svelte-i18n-params-values

Conversation

@0froq

@0froq 0froq commented Nov 13, 2026

Copy link
Copy Markdown
Member

Summary

$_('welcome', { values: { name } }) keeps its message params inside values, and ParamsSource had no way to name that property. The svelte-i18n preset recorded no params for such a call, so param-mismatch reported neither the missing name nor the unused who at the call site.

ParamsSource gains property, the dot-separated path to the object that holds the params, and the svelte-i18n preset points it at options.values. The preset's single callee list splits in two: $_, $t, _ and t take message params, while $format, $json, format and json keep their second argument as Intl options.

A call that passes options without values, or none at all, now records [] instead of an unreadable params object, so a missing placeholder still gets reported. An unreadable values source ({ values }, { values: opts }, { values: { ...opts } }) stays unknown and the check skips it.

User prompts

Verification

Repro from the issue: a component with $_('greeting') and $_('welcome', { values: { who: 'Alice', unused: 'Bob' } }) against { "welcome": "Hello {name}" }, checked with the built CLI.

Before (base f49a4d74):

Found no errors.

After (this branch):

src/App.svelte:6:9
 WARNING  The params of "welcome" differ from its placeholders in en: missing name; unused who, unused.  param-mismatch

$_('greeting') stays quiet in both runs, because a call with no options has no params to compare.

Gates run on this branch: pnpm lint, pnpm knip, pnpm typecheck, pnpm test (969 passing), pnpm build, pnpm exec x18n check --strict.

pnpm -C docs run generate --check fails on content/6.references/4.lsp-protocol.md, which is already stale on main and unrelated to this change. The config page this PR regenerates is up to date.

Tests added: scanners.test.ts covers params under values, an options object without it, an unreadable values, a spread, and a string argument skipped before the params object. presets.test.ts covers the issue's component and asserts the diagnostic text and usage.params.

Drafted with an agent (pi, opencode-go/deepseek-v4.1-flash). The human gave the task and corrected the issue state. No human has reviewed the diff yet.

A call such as `$_('welcome', { values: { name } })` kept its params inside
`values`, which `ParamsSource` had no way to name, so `param-mismatch` saw no
params at all and reported neither the missing nor the unused ones.

`ParamsSource` gains `property`, the property of the argument that holds the
params object, and the svelte-i18n preset points it at `options.values`.
A call that passes options without `values`, or none, now reports `[]` rather
than an unreadable params object, so the missing placeholders still show up.

Fixes #156
@vercel

vercel Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
x18n Ready Ready Preview Nov 13, 2026 9:36pm UTC

@0froq 0froq closed this Nov 13, 2026
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.

[svelte-i18n] Interpolation parameters aren't checked inside values

1 participant