diff --git a/.changeset/eight-hornets-punch.md b/.changeset/eight-hornets-punch.md new file mode 100644 index 000000000000..e4ae2217f42e --- /dev/null +++ b/.changeset/eight-hornets-punch.md @@ -0,0 +1,5 @@ +--- +"svelte": patch +--- + +fix: make static `element` property available for the SvelteComponent type diff --git a/packages/svelte/src/index.d.ts b/packages/svelte/src/index.d.ts index bebe69a9bfd4..5239d05f0210 100644 --- a/packages/svelte/src/index.d.ts +++ b/packages/svelte/src/index.d.ts @@ -59,6 +59,9 @@ export class SvelteComponent< Events extends Record = any, Slots extends Record = any > { + /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */ + static element?: typeof HTMLElement; + [prop: string]: any; /** * @deprecated This constructor only exists when using the `asClassComponent` compatibility helper, which diff --git a/packages/svelte/tests/types/component.ts b/packages/svelte/tests/types/component.ts index d4ed55121f19..55477441bb17 100644 --- a/packages/svelte/tests/types/component.ts +++ b/packages/svelte/tests/types/component.ts @@ -8,6 +8,8 @@ import { hydrate } from 'svelte'; +SvelteComponent.element === HTMLElement; + // --------------------------------------------------------------------------- legacy: classes class LegacyComponent extends SvelteComponent< diff --git a/packages/svelte/types/index.d.ts b/packages/svelte/types/index.d.ts index 8da06d13514e..daf59938c687 100644 --- a/packages/svelte/types/index.d.ts +++ b/packages/svelte/types/index.d.ts @@ -60,6 +60,9 @@ declare module 'svelte' { Events extends Record = any, Slots extends Record = any > { + /** The custom element version of the component. Only present if compiled with the `customElement` compiler option */ + static element?: typeof HTMLElement; + [prop: string]: any; /** * @deprecated This constructor only exists when using the `asClassComponent` compatibility helper, which