From 3ea49f41a86b00b87aaa4867101f1e23f5115711 Mon Sep 17 00:00:00 2001 From: Simon Holthausen Date: Wed, 17 Apr 2024 12:41:54 +0200 Subject: [PATCH] remove _explicit_ dance, language tools will generate an overriding constructor instead --- packages/svelte/src/index.d.ts | 32 +++++++++++++------------------- packages/svelte/types/index.d.ts | 32 +++++++++++++------------------- 2 files changed, 26 insertions(+), 38 deletions(-) diff --git a/packages/svelte/src/index.d.ts b/packages/svelte/src/index.d.ts index 3c6cc4f447..f71c62a27e 100644 --- a/packages/svelte/src/index.d.ts +++ b/packages/svelte/src/index.d.ts @@ -27,34 +27,28 @@ type WithBindings = { [Key in keyof T]: Bindable; }; -export type RemoveBindable> = Props extends '_explicit_' & - infer Props - ? { - [Key in keyof Props as Props[Key] extends Binding - ? never - : Key]: Props[Key] extends Bindable ? Value : Props[Key]; - } - : Props; +export type RemoveBindable> = { + [Key in keyof Props as Props[Key] extends Binding + ? never + : Key]: Props[Key] extends Bindable ? Value : Props[Key]; +}; type StripBindable> = { [Key in keyof Props]: Props[Key] extends Bindable ? Value : Props[Key]; }; -// Utility types 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 not explicitly opted in, all props are bindable - -type PropsWithChildren = PropsWithBindings & +/** + * 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 + * - All props are bindable + */ +type PropsWithChildren = WithBindings & (Props extends { children?: any } ? {} : Slots extends { default: any } ? { children?: Snippet } : {}); -type PropsWithBindings = Props extends '_explicit_' & infer ActualProps - ? ActualProps - : WithBindings; - /** * Can be used to create strongly typed Svelte components. * @@ -84,7 +78,7 @@ type PropsWithBindings = Props extends '_explicit_' & infer ActualProps * for more info. */ export class SvelteComponent< - Props extends Record | (Record & '_explicit_') = Record, + Props extends Record = Record, Events extends Record = any, Slots extends Record = any > { @@ -148,7 +142,7 @@ export class SvelteComponent< * @deprecated Use `SvelteComponent` instead. See TODO for more information. */ export class SvelteComponentTyped< - Props extends Record | (Record & '_explicit_') = Record, + Props extends Record = Record, Events extends Record = any, Slots extends Record = any > extends SvelteComponent {} diff --git a/packages/svelte/types/index.d.ts b/packages/svelte/types/index.d.ts index 46542e80bb..92b5c84b5b 100644 --- a/packages/svelte/types/index.d.ts +++ b/packages/svelte/types/index.d.ts @@ -28,34 +28,28 @@ declare module 'svelte' { [Key in keyof T]: Bindable; }; - export type RemoveBindable> = Props extends '_explicit_' & - infer Props - ? { - [Key in keyof Props as Props[Key] extends Binding - ? never - : Key]: Props[Key] extends Bindable ? Value : Props[Key]; - } - : Props; + export type RemoveBindable> = { + [Key in keyof Props as Props[Key] extends Binding + ? never + : Key]: Props[Key] extends Bindable ? Value : Props[Key]; + }; type StripBindable> = { [Key in keyof Props]: Props[Key] extends Bindable ? Value : Props[Key]; }; - // Utility types 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 not explicitly opted in, all props are bindable - - type PropsWithChildren = PropsWithBindings & + /** + * 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 + * - All props are bindable + */ + type PropsWithChildren = WithBindings & (Props extends { children?: any } ? {} : Slots extends { default: any } ? { children?: Snippet } : {}); - type PropsWithBindings = Props extends '_explicit_' & infer ActualProps - ? ActualProps - : WithBindings; - /** * Can be used to create strongly typed Svelte components. * @@ -85,7 +79,7 @@ declare module 'svelte' { * for more info. */ export class SvelteComponent< - Props extends Record | (Record & '_explicit_') = Record, + Props extends Record = Record, Events extends Record = any, Slots extends Record = any > { @@ -149,7 +143,7 @@ declare module 'svelte' { * @deprecated Use `SvelteComponent` instead. See TODO for more information. */ export class SvelteComponentTyped< - Props extends Record | (Record & '_explicit_') = Record, + Props extends Record = Record, Events extends Record = any, Slots extends Record = any > extends SvelteComponent {}