You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I just faced this issue and it is indeed pretty ugly to have to do this. It's similar for component props, for example for a Shadcn UI Form with Superforms, you end up with something like this for a simple form component:
import{typeSuperValidated,typeInfer,superForm}from"sveltekit-superforms";import{zodClient}from"sveltekit-superforms/adapters";import*asFormfrom"$lib/components/ui/form/index.js";import{Input}from"$lib/components/ui/input/index.js";import{formSchema,typeFormSchema}from"./schema";interfaceFormProps{data: SuperValidated<Infer<FormSchema>>;}const{ data }: FormProps=$props();constform=superForm(data,{validators: zodClient(formSchema),});const{form: formData, enhance }=form;
A +page.svelte file cannot get its props from anything other than the load method, right? So why have the extra "data" variable wrapping? I see why it was needed with Svelte 4, but it feels unnecessary with Svelte 5.
Describe the problem
Sveltekit generate a type
PageData
for each+page.svelte
, which allows to properly type thedata
prop :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 :
Describe the proposed solution
The generated
$types
should include a new typePageProps
, in the following manner :Which would allow us to write directly :
Alternatives considered
Rewrite the $props() type on every page...
Importance
nice to have
Additional Information
No response
The text was updated successfully, but these errors were encountered: