-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Closed
Labels
Description
Describe the problem
Sveltekit generate a type PageData for each +page.svelte, which allows to properly type the data prop :
<!-- Svelte 4 -->
<script lang="ts">
import type { PageData } from './$types';
export let data: PageData;
</script>It's fine with Svelte 4, but with the new syntax in Svelte 5 we have to define an additional type for the $props runes :
<!-- Svelte 5 -->
<script lang="ts">
import type { PageData } from './$types';
type Props = {
data: PageData;
}
let {
data
} : Props = $props();
</script>Describe the proposed solution
The generated $types should include a new type PageProps, in the following manner :
export type PageProps = {
data: PageData;
}Which would allow us to write directly :
<!-- Svelte 5 -->
<script lang="ts">
import type { PageProps } from './$types';
let {
data
} : PageProps = $props();
</script>Alternatives considered
Rewrite the $props() type on every page...
Importance
nice to have
Additional Information
No response
NotWoods, Zinnavoy, weebao, rChaoz and philippone