fix: adjust mount and createRoot types

they expect the component constructor, not the instance
pull/9633/head
Simon Holthausen 1 year ago
parent a3bc7d5698
commit 63e5831846

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: adjust mount and createRoot types

@ -2915,7 +2915,7 @@ export function unwrap(value) {
* @template {Record<string, any>} Props * @template {Record<string, any>} Props
* @template {Record<string, any> | undefined} Exports * @template {Record<string, any> | undefined} Exports
* @template {Record<string, any>} Events * @template {Record<string, any>} Events
* @param {import('../../main/public.js').SvelteComponent<Props, Events>} component * @param {typeof import('../../main/public.js').SvelteComponent<Props, Events>} component
* @param {{ * @param {{
* target: Node; * target: Node;
* props?: Props; * props?: Props;
@ -3034,7 +3034,7 @@ export function createRoot(component, options) {
* @template {Record<string, any>} Props * @template {Record<string, any>} Props
* @template {Record<string, any> | undefined} Exports * @template {Record<string, any> | undefined} Exports
* @template {Record<string, any>} Events * @template {Record<string, any>} Events
* @param {import('../../main/public.js').SvelteComponent<Props, Events>} component * @param {typeof import('../../main/public.js').SvelteComponent<Props, Events>} component
* @param {{ * @param {{
* target: Node; * target: Node;
* props?: Props; * props?: Props;

@ -4,7 +4,8 @@ import {
SvelteComponent, SvelteComponent,
type ComponentEvents, type ComponentEvents,
type ComponentProps, type ComponentProps,
type ComponentType type ComponentType,
mount
} from 'svelte'; } from 'svelte';
// --------------------------------------------------------------------------- legacy: classes // --------------------------------------------------------------------------- legacy: classes
@ -103,7 +104,22 @@ const newComponentEvents2: ComponentEvents<NewComponent> = {
event: new KeyboardEvent('click') event: new KeyboardEvent('click')
}; };
const instance = createRoot(newComponent, { mount(NewComponent, {
target: null as any as Document | Element | ShadowRoot | Text | Comment,
props: {
prop: 'foo',
// @ts-expect-error
x: ''
},
events: {
event: new MouseEvent('click')
},
immutable: true,
intro: false,
recover: false
});
const instance = createRoot(NewComponent, {
target: null as any as Document | Element | ShadowRoot | Text | Comment, target: null as any as Document | Element | ShadowRoot | Text | Comment,
props: { props: {
prop: 'foo', prop: 'foo',

Loading…
Cancel
Save