fix: Honestly idk why it was broken but it's fixed now

pull/10320/head
S. Elliott Johnson 2 years ago
parent a802c92cb6
commit 39d6ed05aa

@ -1,4 +1,16 @@
import type { Snippet } from './public';
/** /**
* Anything except a function * Anything except a function
*/ */
export type NotFunction<T> = T extends Function ? never : T; export type NotFunction<T> = T extends Function ? never : T;
// Utility type for ensuring backwards compatibility on a type level: If there's a default slot, add 'children' to the props if it doesn't exist there already
// if you're curious why this is here and not declared as an unexported type from `public.d.ts`, try putting it there
// and see what happens in the output `index.d.ts` -- it breaks, presumably because of a TypeScript compiler bug.
export type PropsWithChildren<Props, Slots> = Props &
(Props extends { children?: any }
? {}
: Slots extends { default: any }
? { children?: Snippet<[]> }
: {});

@ -18,14 +18,6 @@ export interface ComponentConstructorOptions<
$$inline?: boolean; $$inline?: boolean;
} }
// Utility type for ensuring backwards compatibility on a type level: If there's a default slot, add 'children' to the props if it doesn't exist there already
type PropsWithChildren<Props, Slots> = Props &
(Props extends { children?: any }
? {}
: Slots extends { default: any }
? { children?: Snippet }
: {});
/** /**
* Can be used to create strongly typed Svelte components. * Can be used to create strongly typed Svelte components.
* *
@ -229,3 +221,4 @@ export interface EventDispatcher<EventMap extends Record<string, any>> {
export * from './main-client.js'; export * from './main-client.js';
import './ambient.js'; import './ambient.js';
import type { PropsWithChildren } from './private.js';

@ -19,14 +19,6 @@ declare module 'svelte' {
$$inline?: boolean; $$inline?: boolean;
} }
// Utility type for ensuring backwards compatibility on a type level: If there's a default slot, add 'children' to the props if it doesn't exist there already
type PropsWithChildren<Props, Slots> = Props &
(Props extends { children?: any }
? {}
: Slots extends { default: any }
? { children?: Snippet }
: {});
/** /**
* Can be used to create strongly typed Svelte components. * Can be used to create strongly typed Svelte components.
* *
@ -319,6 +311,14 @@ declare module 'svelte' {
* Anything except a function * Anything except a function
*/ */
type NotFunction<T> = T extends Function ? never : T; type NotFunction<T> = T extends Function ? never : T;
// Utility type for ensuring backwards compatibility on a type level: If there's a default slot, add 'children' to the props if it doesn't exist there already
type PropsWithChildren<Props, Slots> = Props &
(Props extends { children?: any }
? {}
: Slots extends { default: any }
? { children?: Snippet<[]> }
: {});
/** /**
* Mounts the given component to the given target and returns a handle to the component's public accessors * Mounts the given component to the given target and returns a handle to the component's public accessors
* as well as a `$set` and `$destroy` method to update the props of the component or destroy it. * as well as a `$set` and `$destroy` method to update the props of the component or destroy it.
@ -327,13 +327,7 @@ declare module 'svelte' {
* *
* */ * */
export function createRoot<Props extends Record<string, any>, Exports extends Record<string, any> | undefined, Events extends Record<string, any>>(component: { export function createRoot<Props extends Record<string, any>, Exports extends Record<string, any> | undefined, Events extends Record<string, any>>(component: {
new (options: ComponentConstructorOptions<Props & (Props extends { new (options: ComponentConstructorOptions<PropsWithChildren<Props, any>>): SvelteComponent<Props, Events, any>;
children?: any;
} ? {} : {} | {
children?: ((this: void) => unique symbol & {
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
}) | undefined;
})>): SvelteComponent<Props, Events, any>;
}, options: { }, options: {
target: Node; target: Node;
props?: Props | undefined; props?: Props | undefined;
@ -352,13 +346,7 @@ declare module 'svelte' {
* *
* */ * */
export function mount<Props extends Record<string, any>, Exports extends Record<string, any> | undefined, Events extends Record<string, any>>(component: { export function mount<Props extends Record<string, any>, Exports extends Record<string, any> | undefined, Events extends Record<string, any>>(component: {
new (options: ComponentConstructorOptions<Props & (Props extends { new (options: ComponentConstructorOptions<PropsWithChildren<Props, any>>): SvelteComponent<Props, Events, any>;
children?: any;
} ? {} : {} | {
children?: ((this: void) => unique symbol & {
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
}) | undefined;
})>): SvelteComponent<Props, Events, any>;
}, options: { }, options: {
target: Node; target: Node;
props?: Props | undefined; props?: Props | undefined;
@ -1730,15 +1718,7 @@ declare module 'svelte/legacy' {
* *
* */ * */
export function asClassComponent<Props extends Record<string, any>, Exports extends Record<string, any>, Events extends Record<string, any>, Slots extends Record<string, any>>(component: SvelteComponent<Props, Events, Slots>): { export function asClassComponent<Props extends Record<string, any>, Exports extends Record<string, any>, Events extends Record<string, any>, Slots extends Record<string, any>>(component: SvelteComponent<Props, Events, Slots>): {
new (options: ComponentConstructorOptions<Props & (Props extends { new (options: ComponentConstructorOptions<PropsWithChildren<Props, Slots>>): SvelteComponent<Props, Events, Slots>;
children?: any;
} ? {} : Slots extends {
default: any;
} ? {
children?: ((this: void) => unique symbol & {
_: "functions passed to {@render ...} tags must use the `Snippet` type imported from \"svelte\"";
}) | undefined;
} : {})>): SvelteComponent<Props, Events, Slots>;
} & Exports; } & Exports;
// This should contain all the public interfaces (not all of them are actually importable, check current Svelte for which ones are). // This should contain all the public interfaces (not all of them are actually importable, check current Svelte for which ones are).
@ -1760,14 +1740,6 @@ declare module 'svelte/legacy' {
$$inline?: boolean; $$inline?: boolean;
} }
// Utility type for ensuring backwards compatibility on a type level: If there's a default slot, add 'children' to the props if it doesn't exist there already
type PropsWithChildren<Props, Slots> = Props &
(Props extends { children?: any }
? {}
: Slots extends { default: any }
? { children?: Snippet }
: {});
/** /**
* Can be used to create strongly typed Svelte components. * Can be used to create strongly typed Svelte components.
* *
@ -1877,6 +1849,13 @@ declare module 'svelte/legacy' {
_: 'functions passed to {@render ...} tags must use the `Snippet` type imported from "svelte"'; _: 'functions passed to {@render ...} tags must use the `Snippet` type imported from "svelte"';
}; };
}; };
// Utility type for ensuring backwards compatibility on a type level: If there's a default slot, add 'children' to the props if it doesn't exist there already
type PropsWithChildren<Props, Slots> = Props &
(Props extends { children?: any }
? {}
: Slots extends { default: any }
? { children?: Snippet<[]> }
: {});
} }
declare module 'svelte/motion' { declare module 'svelte/motion' {

Loading…
Cancel
Save