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
When you're creating unit-tests for a Svelte 5 component, using Vitest (latest versions of all packages), if you have required properties in the component, they won't be validated by the check and an error will be thrown.
In the test, we'll have a check error saying that: TS2345: Argument of type Component<ComponentProps, {}, ""> is not assignable to parameter of type Component<{}, {}, string> Types of parameters props and props are incompatible. Property name is missing in type {} but required in type ComponentProps types.ts(70, 3): name is declared here.
Expected behaviour
There should be no check error on this, since the required prop is already being sent within the unit test and the test passes.
System Info
OS: Windows
IDE: WebStorm, VSCode
Which package is the issue about?
svelte-check
Additional Information, eg. Screenshots
I've tried something like this, inside the component, using ComponentProps as type for the $props, but it didn't help: type ComponentProps = Pick<InterfaceProps, 'name'> & Partial<Omit<InterfaceProps, 'name'>>;
Because of this issue, I always need to destruct the props this way:
let {
name,
surname,
above,
...rest
}: Partial<ComponentProps> = $props();
This result in having all props as optional and a validation is needed each time you want to use a required prop.
The text was updated successfully, but these errors were encountered:
Describe the bug
When you're creating unit-tests for a Svelte 5 component, using Vitest (latest versions of all packages), if you have required properties in the component, they won't be validated by the check and an error will be thrown.
Reproduction
Let's say we have an interface like this:
Notice that the
name
property is required.Using this interface into the Svelte 5 component:
Then we have the unit-test (using Vitest):
In the test, we'll have a check error saying that:
TS2345: Argument of type Component<ComponentProps, {}, ""> is not assignable to parameter of type Component<{}, {}, string> Types of parameters props and props are incompatible. Property name is missing in type {} but required in type ComponentProps types.ts(70, 3): name is declared here.
Expected behaviour
There should be no check error on this, since the required prop is already being sent within the unit test and the test passes.
System Info
Which package is the issue about?
svelte-check
Additional Information, eg. Screenshots
I've tried something like this, inside the component, using
ComponentProps
as type for the$props
, but it didn't help:type ComponentProps = Pick<InterfaceProps, 'name'> & Partial<Omit<InterfaceProps, 'name'>>;
Because of this issue, I always need to destruct the props this way:
This result in having all props as optional and a validation is needed each time you want to use a required prop.
The text was updated successfully, but these errors were encountered: