breaking: deprecate SvelteComponentTyped, add generics to SvelteComponent - #8512
Merged
dummdidumm merged 3 commits intoApr 24, 2023
Merged
Conversation
…nent Also add data- attribute to HTMLAttributes and use available TS interfaces
Contributor
|
@dummdidumm is attempting to deploy a commit to the Svelte Team on Vercel. A member of the Team first needs to authorize it. |
baseballyama
approved these changes
Apr 23, 2023
| * 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 |
Member
There was a problem hiding this comment.
Can we remove SvelteComponentTyped completely if we will release this PR in Svelte4 because this is a major version up?
Member
Author
There was a problem hiding this comment.
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.
5 tasks
3 tasks
This was referenced Jun 24, 2023
jiangfengming
added a commit
to svelte-pilot/svelte-pilot
that referenced
this pull request
Jun 27, 2023
Rinrin0413
added a commit
to Rinrin0413/rinrin0413.github.io
that referenced
this pull request
Sep 27, 2023
] `SvelteComponentTyped` is deprecated in Svelte 4. I gonna move to Svelte 4 in the future so. See also: sveltejs/svelte#8512
fmaclen
added a commit
to fmaclen/svelte-currency-input
that referenced
this pull request
Nov 10, 2023
- 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
fmaclen
added a commit
to fmaclen/svelte-currency-input
that referenced
this pull request
Nov 10, 2023
- 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
25 tasks
18 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Breaking change / how to migrate
SvelteComponentnow has the same capabilities asSvelteComponenTyped, which is therefore now deprecated. UseSvelteComponentwhere you've usedSvelteComponentTypedpreviously:In case you've used
SvelteComponentpreviously 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 testand lint the project withnpm run lint