fix: relax constraint for ComponentProps (#12026)

`Component` with any props should be allowed to pass in
pull/12015/head
Simon H 6 months ago committed by GitHub
parent 0119f25125
commit 9dc2d71a12
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
"svelte": patch
---
fix: relax constraint for `ComponentProps`

@ -198,7 +198,7 @@ export type ComponentEvents<Comp extends SvelteComponent> =
* </script>
* ```
*/
export type ComponentProps<Comp extends SvelteComponent | Component> =
export type ComponentProps<Comp extends SvelteComponent | Component<any>> =
Comp extends SvelteComponent<infer Props>
? Props
: Comp extends Component<infer Props>

@ -231,6 +231,13 @@ functionComponentInstance.foo === 'bar';
// @ts-expect-error
functionComponentInstance.foo = 'foo';
const functionComponentProps: ComponentProps<typeof functionComponent> = {
binding: true,
readonly: 'foo',
// @ts-expect-error
prop: 1
};
mount(functionComponent, {
target: null as any as Document | Element | ShadowRoot,
props: {

@ -195,7 +195,7 @@ declare module 'svelte' {
* </script>
* ```
*/
export type ComponentProps<Comp extends SvelteComponent | Component> =
export type ComponentProps<Comp extends SvelteComponent | Component<any>> =
Comp extends SvelteComponent<infer Props>
? Props
: Comp extends Component<infer Props>

Loading…
Cancel
Save