Skip to content

Commit 2784fb1

Browse files
authored
Revert "feat: add ComponentExports utility type (#13441)" (#14069)
This reverts commit d93ad3b.
1 parent 4f80ab6 commit 2784fb1

File tree

4 files changed

+1
-70
lines changed

4 files changed

+1
-70
lines changed

.changeset/rotten-cups-float.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

packages/svelte/src/index.d.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -237,26 +237,6 @@ export type ComponentProps<Comp extends SvelteComponent | Component<any, any>> =
237237
? Props
238238
: never;
239239

240-
/**
241-
* Convenience type to get the properties that given component exports.
242-
*
243-
* Example: Typing the `bind:this` for a component named `MyComponent`
244-
* ```
245-
* <script lang="ts">
246-
* import MyComponent from '$lib/component';
247-
* let component: ComponentExports<typeof MyComponent> | undefined = undefined;
248-
* <script>
249-
*
250-
* <MyComponent bind:this={component} />
251-
* ```
252-
*/
253-
export type ComponentExports<TComponent extends Component<any, any> | typeof SvelteComponent<any>> =
254-
TComponent extends typeof SvelteComponent<any>
255-
? InstanceType<TComponent>
256-
: TComponent extends Component<any, infer TExports>
257-
? TExports
258-
: never;
259-
260240
/**
261241
* @deprecated This type is obsolete when working with the new `Component` type.
262242
*

packages/svelte/tests/types/component.ts

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@ import {
77
mount,
88
hydrate,
99
type Component,
10-
type ComponentInternals,
11-
type ComponentExports
10+
type ComponentInternals
1211
} from 'svelte';
1312
import { render } from 'svelte/server';
1413

@@ -181,16 +180,6 @@ render(NewComponent, {
181180
}
182181
});
183182

184-
const newComponentExports: ComponentExports<typeof NewComponent> = {
185-
anExport: '',
186-
$$events_def: null as any,
187-
$$prop_def: null as any,
188-
$$slot_def: null as any,
189-
$set: null as any,
190-
$destroy: null as any,
191-
$on: null as any
192-
};
193-
194183
// --------------------------------------------------------------------------- interop
195184

196185
const AsLegacyComponent = asClassComponent(newComponent);
@@ -348,19 +337,6 @@ render(functionComponent, {
348337
}
349338
});
350339

351-
const functionComponentExports: ComponentExports<typeof functionComponent> = {
352-
foo: 'bar',
353-
// @ts-expect-error
354-
x: ''
355-
};
356-
357-
type AdhocFunctionComponent = (a: unknown, b: { a: true }) => { foo: string };
358-
const adhocFunctionComponentExport: ComponentExports<AdhocFunctionComponent> = {
359-
foo: 'bar',
360-
// @ts-expect-error
361-
x: ''
362-
};
363-
364340
// --------------------------------------------------------------------------- *.svelte components
365341

366342
// import from a nonexistent file to trigger the declare module '*.svelte' in ambient.d.ts

packages/svelte/types/index.d.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -234,26 +234,6 @@ declare module 'svelte' {
234234
? Props
235235
: never;
236236

237-
/**
238-
* Convenience type to get the properties that given component exports.
239-
*
240-
* Example: Typing the `bind:this` for a component named `MyComponent`
241-
* ```
242-
* <script lang="ts">
243-
* import MyComponent from '$lib/component';
244-
* let component: ComponentExports<typeof MyComponent> | undefined = undefined;
245-
* <script>
246-
*
247-
* <MyComponent bind:this={component} />
248-
* ```
249-
*/
250-
export type ComponentExports<TComponent extends Component<any, any> | typeof SvelteComponent<any>> =
251-
TComponent extends typeof SvelteComponent<any>
252-
? InstanceType<TComponent>
253-
: TComponent extends Component<any, infer TExports>
254-
? TExports
255-
: never;
256-
257237
/**
258238
* @deprecated This type is obsolete when working with the new `Component` type.
259239
*

0 commit comments

Comments
 (0)