Skip to content

Commit 8214075

Browse files
authored
fix: update type of options.target (#10892)
1 parent 1fc5f8b commit 8214075

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-7
lines changed

.changeset/metal-lobsters-burn.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'svelte': patch
3+
---
4+
5+
fix: update type of `options.target`

packages/svelte/src/internal/client/render.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ export function createRoot() {
105105
* @template {Record<string, any>} Events
106106
* @param {import('../../main/public.js').ComponentType<import('../../main/public.js').SvelteComponent<Props, Events>>} component
107107
* @param {{
108-
* target: Node;
108+
* target: Document | Element | ShadowRoot;
109109
* props?: Props;
110110
* events?: { [Property in keyof Events]: (e: Events[Property]) => any };
111111
* context?: Map<any, any>;
@@ -127,7 +127,7 @@ export function mount(component, options) {
127127
* @template {Record<string, any>} Events
128128
* @param {import('../../main/public.js').ComponentType<import('../../main/public.js').SvelteComponent<Props, Events>>} component
129129
* @param {{
130-
* target: Node;
130+
* target: Document | Element | ShadowRoot;
131131
* props?: Props;
132132
* events?: { [Property in keyof Events]: (e: Events[Property]) => any };
133133
* context?: Map<any, any>;
@@ -190,7 +190,7 @@ export function hydrate(component, options) {
190190
* @template {Record<string, any>} Events
191191
* @param {import('../../main/public.js').ComponentType<import('../../main/public.js').SvelteComponent<Props, Events>>} Component
192192
* @param {{
193-
* target: Node;
193+
* target: Document | Element | ShadowRoot;
194194
* anchor: null | Text;
195195
* props?: Props;
196196
* events?: { [Property in keyof Events]: (e: Events[Property]) => any };

packages/svelte/tests/types/component.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const newComponentEvents2: ComponentEvents<NewComponent> = {
105105
};
106106

107107
mount(NewComponent, {
108-
target: null as any as Document | Element | ShadowRoot | Text | Comment,
108+
target: null as any as Document | Element | ShadowRoot,
109109
props: {
110110
prop: 'foo',
111111
// @ts-expect-error
@@ -120,7 +120,7 @@ mount(NewComponent, {
120120
});
121121

122122
hydrate(NewComponent, {
123-
target: null as any as Document | Element | ShadowRoot | Text | Comment,
123+
target: null as any as Document | Element | ShadowRoot,
124124
props: {
125125
prop: 'foo',
126126
// @ts-expect-error

packages/svelte/types/index.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ declare module 'svelte' {
300300
*
301301
* */
302302
export function mount<Props extends Record<string, any>, Exports extends Record<string, any>, Events extends Record<string, any>>(component: ComponentType<SvelteComponent<Props, Events, any>>, options: {
303-
target: Node;
303+
target: Document | Element | ShadowRoot;
304304
props?: Props | undefined;
305305
events?: { [Property in keyof Events]: (e: Events[Property]) => any; } | undefined;
306306
context?: Map<any, any> | undefined;
@@ -311,7 +311,7 @@ declare module 'svelte' {
311311
*
312312
* */
313313
export function hydrate<Props extends Record<string, any>, Exports extends Record<string, any>, Events extends Record<string, any>>(component: ComponentType<SvelteComponent<Props, Events, any>>, options: {
314-
target: Node;
314+
target: Document | Element | ShadowRoot;
315315
props?: Props | undefined;
316316
events?: { [Property in keyof Events]: (e: Events[Property]) => any; } | undefined;
317317
context?: Map<any, any> | undefined;

0 commit comments

Comments
 (0)