Replies: 3 comments 1 reply
-
Note: export const sections = $state<SectionClass>(); Will make the type of export const sections: Writable<SectionClass> = writable(); Will only make the type of |
Beta Was this translation helpful? Give feedback.
0 replies
-
You will need an assertion since export const sections: SectionClass = $state()!;
// or
export const sections = $state<SectionClass>()!;
// or
export const sections: SectionClass = $state() as any; |
Beta Was this translation helpful? Give feedback.
1 reply
-
Try |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi, I have a general question on how to initiate things in $state rune to replace store. Say the following code:
If I do it in $state rune like this:
Typescript will tell me:
However, I do not want to do either of the following two things:
Is there something equivalent to
Writable<SectionClass>
type declaration for $state rune? Can I say my variable is a $state of SectionClass without even initializing its values? If this is possible, could we add it to the documentation?Beta Was this translation helpful? Give feedback.
All reactions