-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Provide augmented HTML typings in SvelteKit itself #10534
Comments
I am trying to hook into this approach to limit custom props to specific elements (following the guide here https://github.com/sveltejs/language-tools/blob/master/docs/preprocessors/typescript.md#im-using-an-attributeevent-on-a-dom-element-and-it-throws-a-type-error I made the following code: declare namespace svelteHTML {
interface HTMLAttributes {
variant?: 'primary' | 'secondary';
}
} <button variant="primary">Test</button>
<button>Test none</button>
<button variant="tertiary">Test</button>
<p variant="primary">Test</p> The goal would be that I get two warnings: for This does only give an error on I tried the following so far:
both using |
Usage of I also realized that the addition of |
This makes it possible to delete these from svelte/elements in Svelte 5 and have them controled in SvelteKit, decoupling the two closes #10534
This makes it possible to delete these from svelte/elements in Svelte 5 and have them controled in SvelteKit, decoupling the two closes #10534
Describe the problem
Right now, things like
data-sveltekit-preload-data
are added inside the Svelte repo's HTML type definitions. With sveltejs/language-tools#2109 adressed we can investigate whether or not it makes sense to have these additional types provided by SvelteKit itself.Describe the proposed solution
Have a file inside SvelteKit that is loaded through the generated
ambient.d.ts
file which enhances the typings like this.Alternatives considered
keep the tighter-than-it-needs-to-be-connection to Svelte's typings.
Importance
would make my life easier
Additional Information
I haven't quite figured out if this is a breaking change or not - i.e. is there something stopping us from just shipping this today and then removing the types in a future Svelte version, which the next major version then only supports? It's probably a breaking change because it would mean we need to remove the typings on the Svelte core side, so probably easiest to do along with Svelte 5.
The text was updated successfully, but these errors were encountered: