Skip to content

feat: looseAttributePrefixes option to exempt prefixed attributes from type checking - #3089

Open
khromov wants to merge 3 commits into
sveltejs:masterfrom
khromov:loose-attribute-prefixes
Open

feat: looseAttributePrefixes option to exempt prefixed attributes from type checking#3089
khromov wants to merge 3 commits into
sveltejs:masterfrom
khromov:loose-attribute-prefixes

Conversation

@khromov

@khromov khromov commented Jul 30, 2026

Copy link
Copy Markdown

Attributes whose names start with a prefix configured via svelteOptions.looseAttributePrefixes in tsconfig/jsconfig are treated like data-* attributes (spread into __sveltets_2_empty), on both elements and components. Useful for preprocessors that consume namespaced template directives before the Svelte compiler runs.

Plumbed through the language server (TS and tsgo paths), the typescript-plugin, and svelte-check's incremental mode (with cache invalidation when the option changes).

This is a small patch so we can avoid doing this ugly svelte-check patch in Mochi.

khromov added 2 commits July 30, 2026 20:18
…m type checking

Attributes whose names start with a prefix configured via svelteOptions.looseAttributePrefixes
in tsconfig/jsconfig are treated like data-* attributes (spread into __sveltets_2_empty),
on both elements and components. Useful for preprocessors that consume namespaced template
directives before the Svelte compiler runs.

Plumbed through the language server (TS and tsgo paths), the typescript-plugin, and
svelte-check's incremental mode (with cache invalidation when the option changes).
…and docs note

- Move sanitizeLooseAttributePrefixes into svelte2tsx internalHelpers and
  apply it inside convertHtmlxToJsx so all entry points are guarded
- Reuse the shared helper in language-server, svelte-check and
  typescript-plugin (closes the unsanitized path in the plugin)
- Add changeset for the new feature
- Document that svelteOptions is not picked up through tsconfig extends
@changeset-bot

changeset-bot Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: cb87ee3

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 4 packages
Name Type
svelte2tsx Minor
svelte-language-server Minor
svelte-check Minor
typescript-svelte-plugin Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

1 participant