fix: export temporary LegacyComponentType (#14256) (#14257)

closes  #14256

helps TypeScript when generating dts files to not fail
pull/14414/head
Theodor Steiner 1 month ago committed by GitHub
parent 046900876f
commit e721d96d32
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,5 @@
---
'svelte': patch
---
fix: provide temporary `LegacyComponentType`

@ -1,17 +1,9 @@
declare module '*.svelte' { declare module '*.svelte' {
// use prettier-ignore for a while because of https://github.com/sveltejs/language-tools/commit/026111228b5814a9109cc4d779d37fb02955fb8b // use prettier-ignore for a while because of https://github.com/sveltejs/language-tools/commit/026111228b5814a9109cc4d779d37fb02955fb8b
// prettier-ignore // prettier-ignore
import { SvelteComponent, Component, type ComponentConstructorOptions } from 'svelte' import { SvelteComponent } from 'svelte'
import { LegacyComponentType } from 'svelte/legacy';
// Support using the component as both a class and function during the transition period const Comp: LegacyComponentType;
// prettier-ignore
interface ComponentType {
(
...args: Parameters<Component<Record<string, any>>>
): ReturnType<Component<Record<string, any>, Record<string, any>>>
new (o: ComponentConstructorOptions): SvelteComponent
}
const Comp: ComponentType;
type Comp = SvelteComponent; type Comp = SvelteComponent;
export default Comp; export default Comp;
} }

@ -63,6 +63,11 @@ export function asClassComponent(component) {
}; };
} }
/**
* Support using the component as both a class and function during the transition period
* @typedef {{new (o: ComponentConstructorOptions): SvelteComponent;(...args: Parameters<Component<Record<string, any>>>): ReturnType<Component<Record<string, any>, Record<string, any>>>;}} LegacyComponentType
*/
class Svelte4Component { class Svelte4Component {
/** @type {any} */ /** @type {any} */
#events; #events;

@ -1578,6 +1578,13 @@ declare module 'svelte/legacy' {
* @deprecated Use this only as a temporary solution to migrate your automatically delegated events in Svelte 5. * @deprecated Use this only as a temporary solution to migrate your automatically delegated events in Svelte 5.
*/ */
export function createBubbler(): (type: string) => (event: Event) => boolean; export function createBubbler(): (type: string) => (event: Event) => boolean;
/**
* Support using the component as both a class and function during the transition period
*/
export type LegacyComponentType = {
new (o: ComponentConstructorOptions): SvelteComponent;
(...args: Parameters<Component<Record<string, any>>>): ReturnType<Component<Record<string, any>, Record<string, any>>>;
};
/** /**
* Substitute for the `trusted` event modifier * Substitute for the `trusted` event modifier
* @deprecated * @deprecated
@ -2308,17 +2315,9 @@ declare module 'svelte/types/compiler/interfaces' {
}declare module '*.svelte' { }declare module '*.svelte' {
// use prettier-ignore for a while because of https://github.com/sveltejs/language-tools/commit/026111228b5814a9109cc4d779d37fb02955fb8b // use prettier-ignore for a while because of https://github.com/sveltejs/language-tools/commit/026111228b5814a9109cc4d779d37fb02955fb8b
// prettier-ignore // prettier-ignore
import { SvelteComponent, Component, type ComponentConstructorOptions } from 'svelte' import { SvelteComponent } from 'svelte'
import { LegacyComponentType } from 'svelte/legacy';
// Support using the component as both a class and function during the transition period const Comp: LegacyComponentType;
// prettier-ignore
interface ComponentType {
(
...args: Parameters<Component<Record<string, any>>>
): ReturnType<Component<Record<string, any>, Record<string, any>>>
new (o: ComponentConstructorOptions): SvelteComponent
}
const Comp: ComponentType;
type Comp = SvelteComponent; type Comp = SvelteComponent;
export default Comp; export default Comp;
} }

Loading…
Cancel
Save