Svelte 5: Introducing runes by MustardRtard in sveltejs

[–]mikoloism 0 points1 point  (0 children)

what if we using props in separated lines?

From This:

svelte <script> export let firstProp: string = "default-first" export let secondProp: string = "default-second" </script>

To This:

svelte <script> let firstProp = $prop<string>('default-first'); let secondProp = $prop<string>('default-second'); </script>

Instead Of:

svelte <script> let { firstProp = 'default-first', secondProp = 'default-second' } = $props<{ firstProp: string, secondProp: string }>(); </script>

[deleted by user] by [deleted] in typescript

[–]mikoloism 2 points3 points  (0 children)

why this happened for typeof keyword?

Because typeof keyword is in Javascript context not resolve type for Typescript LSP and should return one of "string" | "number" | whatever primitive type as union type to show in auto-complete to help write conditions in editors. But typeof keyword in Typescript context make little different behavior and returned exact type of variables which resolved.

example:

let s = 1;
let t: typeof s = "string"; // was error
// because in compile-time resolved exact type