-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
breaking: deprecate SvelteComponentTyped, add generics to SvelteComponent #8512
breaking: deprecate SvelteComponentTyped, add generics to SvelteComponent #8512
Conversation
…nent Also add data- attribute to HTMLAttributes and use available TS interfaces
@dummdidumm is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
* const component: typeof SvelteComponent = ASubclassOfSvelteComponent; | ||
* ``` | ||
* will throw a type error, so we need to separate the more strictly typed class. | ||
* @deprecated Use `SvelteComponent` instead. See PR for more information: https://github.com/sveltejs/svelte/pull/8512 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove SvelteComponentTyped
completely if we will release this PR in Svelte4 because this is a major version up?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could but I think it's better to do that in Svelte 5 to give people time to gracefully update their code. Also if some use components built for Svelte 3 which you can otherwise use in Svelte 4 we shouldn't block that just because the class was removed. Right now svelte package uses SvelteCompentTyped in the generated d.ts files.
] `SvelteComponentTyped` is deprecated in Svelte 4. I gonna move to Svelte 4 in the future so. See also: sveltejs/svelte#8512
- REF https://kit.svelte.dev/docs/packaging#anatomy-of-a-package-json-svelte - Downgrade to Svelte 3.59.2 because 4.0.0 exports the package using a type `SvelteComponent` which causes the types to break when used in Svelte 3.x — REF sveltejs/svelte#8512 Fixes #68
- REF https://kit.svelte.dev/docs/packaging#anatomy-of-a-package-json-svelte - Downgrade to Svelte 3.59.2 because 4.0.0 exports the package using a type `SvelteComponent` which causes the types to break when used in Svelte 3.x — REF sveltejs/svelte#8512 Fixes #68
Breaking change / how to migrate
SvelteComponent
now has the same capabilities asSvelteComponenTyped
, which is therefore now deprecated. UseSvelteComponent
where you've usedSvelteComponentTyped
previously:In case you've used
SvelteComponent
previously to type "I expect a Svelte component constructor here" by usingtypeof SvelteComponent
, you'll now likely get a somewhat opaque TypeScript error.Code:
Error:
The solution is to either add
<any>
totypeof SvelteComponent
(which is possible since TypeScript version 4.7) or doComponentType<SvelteComponent>
instead:PR description
Deprecate SvelteComponentTyped, add generics to SvelteComponent - reverts the revert in #5738. Also add data- attribute to HTMLAttributes (for sveltejs/language-tools#1825) and use available TS interfaces.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.Tests
npm test
and lint the project withnpm run lint