1- /* eslint-disable @typescript-eslint/no-explicit-any */
1+ /* eslint-disable @typescript-eslint/no-explicit-any, @typescript-eslint/no-redundant-type-constituents */
22import type * as Svelte from 'svelte'
33
4- type IS_MODERN_SVELTE = any extends Svelte . Component ? false : true
4+ type IS_MODERN_SVELTE = Svelte . Component extends ( ...args : any [ ] ) => any
5+ ? true
6+ : false
57
68/** A compiled, imported Svelte component. */
79export type Component <
@@ -14,21 +16,21 @@ export type Component<
1416/**
1517 * The type of an imported, compiled Svelte component.
1618 *
17- * In Svelte 4, this was the Svelte component class' type.
1819 * In Svelte 5, this distinction no longer matters.
20+ * In Svelte 4, this is the Svelte component class constructor.
1921 */
20- export type ComponentType < C > = C extends Svelte . SvelteComponent
21- ? Svelte . ComponentType < C >
22- : C
22+ export type ComponentType < C > = IS_MODERN_SVELTE extends true
23+ ? C
24+ : new ( ... args : any [ ] ) => C
2325
2426/** The props of a component. */
2527export type Props < C extends Component < any , any > > = Svelte . ComponentProps < C >
2628
2729/**
2830 * The exported fields of a component.
2931 *
30- * In Svelte 4, this is simply the instance of the component class.
3132 * In Svelte 5, this is the set of variables marked as `export`'d.
33+ * In Svelte 4, this is simply the instance of the component class.
3234 */
3335export type Exports < C > = C extends Svelte . SvelteComponent
3436 ? C
0 commit comments