Revert "feat: add `ComponentExports` utility type (#13441)" (#14069)

This reverts commit d93ad3ba1e.
pull/14052/head
Rich Harris 2 months ago committed by GitHub
parent 4f80ab6da6
commit 2784fb19f3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -1,5 +0,0 @@
---
'svelte': patch
---
chore: provide `ComponentExports` utility type

@ -237,26 +237,6 @@ export type ComponentProps<Comp extends SvelteComponent | Component<any, any>> =
? Props
: never;
/**
* Convenience type to get the properties that given component exports.
*
* Example: Typing the `bind:this` for a component named `MyComponent`
* ```
* <script lang="ts">
* import MyComponent from '$lib/component';
* let component: ComponentExports<typeof MyComponent> | undefined = undefined;
* <script>
*
* <MyComponent bind:this={component} />
* ```
*/
export type ComponentExports<TComponent extends Component<any, any> | typeof SvelteComponent<any>> =
TComponent extends typeof SvelteComponent<any>
? InstanceType<TComponent>
: TComponent extends Component<any, infer TExports>
? TExports
: never;
/**
* @deprecated This type is obsolete when working with the new `Component` type.
*

@ -7,8 +7,7 @@ import {
mount,
hydrate,
type Component,
type ComponentInternals,
type ComponentExports
type ComponentInternals
} from 'svelte';
import { render } from 'svelte/server';
@ -181,16 +180,6 @@ render(NewComponent, {
}
});
const newComponentExports: ComponentExports<typeof NewComponent> = {
anExport: '',
$$events_def: null as any,
$$prop_def: null as any,
$$slot_def: null as any,
$set: null as any,
$destroy: null as any,
$on: null as any
};
// --------------------------------------------------------------------------- interop
const AsLegacyComponent = asClassComponent(newComponent);
@ -348,19 +337,6 @@ render(functionComponent, {
}
});
const functionComponentExports: ComponentExports<typeof functionComponent> = {
foo: 'bar',
// @ts-expect-error
x: ''
};
type AdhocFunctionComponent = (a: unknown, b: { a: true }) => { foo: string };
const adhocFunctionComponentExport: ComponentExports<AdhocFunctionComponent> = {
foo: 'bar',
// @ts-expect-error
x: ''
};
// --------------------------------------------------------------------------- *.svelte components
// import from a nonexistent file to trigger the declare module '*.svelte' in ambient.d.ts

@ -234,26 +234,6 @@ declare module 'svelte' {
? Props
: never;
/**
* Convenience type to get the properties that given component exports.
*
* Example: Typing the `bind:this` for a component named `MyComponent`
* ```
* <script lang="ts">
* import MyComponent from '$lib/component';
* let component: ComponentExports<typeof MyComponent> | undefined = undefined;
* <script>
*
* <MyComponent bind:this={component} />
* ```
*/
export type ComponentExports<TComponent extends Component<any, any> | typeof SvelteComponent<any>> =
TComponent extends typeof SvelteComponent<any>
? InstanceType<TComponent>
: TComponent extends Component<any, infer TExports>
? TExports
: never;
/**
* @deprecated This type is obsolete when working with the new `Component` type.
*

Loading…
Cancel
Save