Skip to content

Commit e721d96

Browse files
authored
fix: export temporary LegacyComponentType (#14256) (#14257)
closes #14256 helps TypeScript when generating dts files to not fail
1 parent 0469008 commit e721d96

File tree

4 files changed

+23
-22
lines changed

4 files changed

+23
-22
lines changed

.changeset/lovely-mayflies-sing.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: provide temporary `LegacyComponentType`

packages/svelte/src/ambient.d.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,9 @@
11
declare module '*.svelte' {
22
// use prettier-ignore for a while because of https://github.com/sveltejs/language-tools/commit/026111228b5814a9109cc4d779d37fb02955fb8b
33
// prettier-ignore
4-
import { SvelteComponent, Component, type ComponentConstructorOptions } from 'svelte'
5-
6-
// Support using the component as both a class and function during the transition period
7-
// prettier-ignore
8-
interface ComponentType {
9-
(
10-
...args: Parameters<Component<Record<string, any>>>
11-
): ReturnType<Component<Record<string, any>, Record<string, any>>>
12-
new (o: ComponentConstructorOptions): SvelteComponent
13-
}
14-
const Comp: ComponentType;
4+
import { SvelteComponent } from 'svelte'
5+
import { LegacyComponentType } from 'svelte/legacy';
6+
const Comp: LegacyComponentType;
157
type Comp = SvelteComponent;
168
export default Comp;
179
}

packages/svelte/src/legacy/legacy-client.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,11 @@ export function asClassComponent(component) {
6363
};
6464
}
6565

66+
/**
67+
* Support using the component as both a class and function during the transition period
68+
* @typedef {{new (o: ComponentConstructorOptions): SvelteComponent;(...args: Parameters<Component<Record<string, any>>>): ReturnType<Component<Record<string, any>, Record<string, any>>>;}} LegacyComponentType
69+
*/
70+
6671
class Svelte4Component {
6772
/** @type {any} */
6873
#events;

packages/svelte/types/index.d.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,6 +1578,13 @@ declare module 'svelte/legacy' {
15781578
* @deprecated Use this only as a temporary solution to migrate your automatically delegated events in Svelte 5.
15791579
*/
15801580
export function createBubbler(): (type: string) => (event: Event) => boolean;
1581+
/**
1582+
* Support using the component as both a class and function during the transition period
1583+
*/
1584+
export type LegacyComponentType = {
1585+
new (o: ComponentConstructorOptions): SvelteComponent;
1586+
(...args: Parameters<Component<Record<string, any>>>): ReturnType<Component<Record<string, any>, Record<string, any>>>;
1587+
};
15811588
/**
15821589
* Substitute for the `trusted` event modifier
15831590
* @deprecated
@@ -2308,17 +2315,9 @@ declare module 'svelte/types/compiler/interfaces' {
23082315
}declare module '*.svelte' {
23092316
// use prettier-ignore for a while because of https://github.com/sveltejs/language-tools/commit/026111228b5814a9109cc4d779d37fb02955fb8b
23102317
// prettier-ignore
2311-
import { SvelteComponent, Component, type ComponentConstructorOptions } from 'svelte'
2312-
2313-
// Support using the component as both a class and function during the transition period
2314-
// prettier-ignore
2315-
interface ComponentType {
2316-
(
2317-
...args: Parameters<Component<Record<string, any>>>
2318-
): ReturnType<Component<Record<string, any>, Record<string, any>>>
2319-
new (o: ComponentConstructorOptions): SvelteComponent
2320-
}
2321-
const Comp: ComponentType;
2318+
import { SvelteComponent } from 'svelte'
2319+
import { LegacyComponentType } from 'svelte/legacy';
2320+
const Comp: LegacyComponentType;
23222321
type Comp = SvelteComponent;
23232322
export default Comp;
23242323
}

0 commit comments

Comments
 (0)