Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: export private legacy ComponentType (#14256) #14257

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/lovely-mayflies-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'svelte': patch
---

fix: export private legacy ComponentType
dummdidumm marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 3 additions & 11 deletions packages/svelte/src/ambient.d.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,9 @@
declare module '*.svelte' {
// use prettier-ignore for a while because of https://github.com/sveltejs/language-tools/commit/026111228b5814a9109cc4d779d37fb02955fb8b
// prettier-ignore
import { SvelteComponent, Component, type ComponentConstructorOptions } from 'svelte'

// Support using the component as both a class and function during the transition period
// 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;
import { SvelteComponent } from 'svelte'
import { LegacyComponentType } from 'svelte/legacy';
const Comp: LegacyComponentType;
type Comp = SvelteComponent;
export default Comp;
}
Expand Down
5 changes: 5 additions & 0 deletions packages/svelte/src/legacy/legacy-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/** @type {any} */
#events;
Expand Down
21 changes: 10 additions & 11 deletions packages/svelte/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
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
* @deprecated
Expand Down Expand Up @@ -2308,17 +2315,9 @@ declare module 'svelte/types/compiler/interfaces' {
}declare module '*.svelte' {
// use prettier-ignore for a while because of https://github.com/sveltejs/language-tools/commit/026111228b5814a9109cc4d779d37fb02955fb8b
// prettier-ignore
import { SvelteComponent, Component, type ComponentConstructorOptions } from 'svelte'

// Support using the component as both a class and function during the transition period
// 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;
import { SvelteComponent } from 'svelte'
import { LegacyComponentType } from 'svelte/legacy';
const Comp: LegacyComponentType;
type Comp = SvelteComponent;
export default Comp;
}
Expand Down
Loading