-
-
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
Can Svelte export all store's Typescript definitions? #5864
Comments
Type definitions should be available here, but I am afraid not for the store: Why would you use a helper function outside of the subscriber function? |
Sometimes we need that for code organization. Using Typescript Declaration Merging to manually export those store types is the best work around at the moment. I also feel like we need a Svelte Typescript Cheatsheet (like the React Typescript one) |
I have the same need. |
Some further info:
I can think of 2 things that could be done:
|
Option 2 is ideal. |
Inspected further and there are some store types that are only internally useful and don't need to be exported. Check out the PR link above |
Is your feature request related to a problem? Please describe.
Take this simple store as an example:
The problem is that I can't type
helper
's argument and return types because there are some internal Svelte types that are not exported:This applies to many other internal types in
svelte/store
, too, ie. The below is not exported:Describe the solution you'd like
I would like to be able to write:
The same would apply to other features of Svelte, too.
This means Svelte would have to export (almost) all of its Typescript definitions in
svelte/store
Describe alternatives you've considered
I've looked at Type Inference but that's fairly inconvenient for dev. I'd prefer to directly use Svelte's internal type definitions.
How important is this feature to you?
I'm looking for a way to use Typescript with Svelte efficiently. This would help a lot with using Typescript in Svelte.
Additional context
Note that I haven't used Svelte a lot. There are maybe better Typescript practices for this Svelte use case that someone can advise?
The text was updated successfully, but these errors were encountered: