@@ -17,29 +17,10 @@ declare module 'svelte' {
1717 $$inline ?: boolean ;
1818 }
1919
20- /** Tooling for types uses this for properties are being used with `bind:` */
21- export type Binding < T > = { 'bind:' : T } ;
2220 /**
23- * Tooling for types uses this for properties that may be bound to.
24- * Only use this if you author Svelte component type definition files by hand (we recommend using `@sveltejs/package` instead).
25- * Example:
26- * ```ts
27- * export class MyComponent extends SvelteComponent<{ readonly: string, bindable: Bindable<string> }> {}
28- * ```
29- * means you can now do `<MyComponent {readonly} bind:bindable />`
30- */
31- export type Bindable < T > = T | Binding < T > ;
32-
33- type WithBindings < T > = {
34- [ Key in keyof T ] : Bindable < T [ Key ] > ;
35- } ;
36-
37- /**
38- * Utility type for ensuring backwards compatibility on a type level:
39- * - If there's a default slot, add 'children' to the props
40- * - All props are bindable
21+ * Utility type for ensuring backwards compatibility on a type level that if there's a default slot, add 'children' to the props
4122 */
42- type PropsWithChildren < Props , Slots > = WithBindings < Props > &
23+ type Properties < Props , Slots > = Props &
4324 ( Slots extends { default : any }
4425 ? // This is unfortunate because it means "accepts no props" turns into "accepts any prop"
4526 // but the alternative is non-fixable type errors because of the way TypeScript index
@@ -91,13 +72,13 @@ declare module 'svelte' {
9172 * is a stop-gap solution. Migrate towards using `mount` or `createRoot` instead. See
9273 * https://svelte-5-preview.vercel.app/docs/breaking-changes#components-are-no-longer-classes for more info.
9374 */
94- constructor ( options : ComponentConstructorOptions < PropsWithChildren < Props , Slots > > ) ;
75+ constructor ( options : ComponentConstructorOptions < Properties < Props , Slots > > ) ;
9576 /**
9677 * For type checking capabilities only.
9778 * Does not exist at runtime.
9879 * ### DO NOT USE!
9980 * */
100- $$prop_def : RemoveBindable < Props > ; // Without PropsWithChildren : unnecessary, causes type bugs
81+ $$prop_def : Props ; // Without Properties : unnecessary, causes type bugs
10182 /**
10283 * For type checking capabilities only.
10384 * Does not exist at runtime.
@@ -112,6 +93,12 @@ declare module 'svelte' {
11293 *
11394 * */
11495 $$slot_def : Slots ;
96+ /**
97+ * For type checking capabilities only.
98+ * Does not exist at runtime.
99+ * ### DO NOT USE!
100+ * */
101+ $$bindings ?: string ;
115102
116103 /**
117104 * @deprecated This method only exists when using one of the legacy compatibility helpers, which
@@ -177,7 +164,7 @@ declare module 'svelte' {
177164 * ```
178165 */
179166 export type ComponentProps < Comp extends SvelteComponent > =
180- Comp extends SvelteComponent < infer Props > ? RemoveBindable < Props > : never ;
167+ Comp extends SvelteComponent < infer Props > ? Props : never ;
181168
182169 /**
183170 * Convenience type to get the type of a Svelte component. Useful for example in combination with
@@ -247,12 +234,6 @@ declare module 'svelte' {
247234 : [ type : Type , parameter : EventMap [ Type ] , options ?: DispatchOptions ]
248235 ) : boolean ;
249236 }
250- /** Anything except a function */
251- type NotFunction < T > = T extends Function ? never : T ;
252-
253- type RemoveBindable < Props extends Record < string , any > > = {
254- [ Key in keyof Props ] : Props [ Key ] extends Bindable < infer Value > ? Value : Props [ Key ] ;
255- } ;
256237 /**
257238 * The `onMount` function schedules a callback to run as soon as the component has been mounted to the DOM.
258239 * It must be called during the component's initialisation (but doesn't need to live *inside* the component;
@@ -323,14 +304,16 @@ declare module 'svelte' {
323304 * Synchronously flushes any pending state changes and those that result from it.
324305 * */
325306 export function flushSync ( fn ?: ( ( ) => void ) | undefined ) : void ;
307+ /** Anything except a function */
308+ type NotFunction < T > = T extends Function ? never : T ;
326309 /**
327310 * Mounts a component to the given target and returns the exports and potentially the props (if compiled with `accessors: true`) of the component
328311 *
329312 * */
330313 export function mount < Props extends Record < string , any > , Exports extends Record < string , any > , Events extends Record < string , any > > ( component : ComponentType < SvelteComponent < Props , Events , any > > , options : {
331314 target : Document | Element | ShadowRoot ;
332315 anchor ?: Node | undefined ;
333- props ?: RemoveBindable < Props > | undefined ;
316+ props ?: Props | undefined ;
334317 events ?: { [ Property in keyof Events ] : ( e : Events [ Property ] ) => any ; } | undefined ;
335318 context ?: Map < any , any > | undefined ;
336319 intro ?: boolean | undefined ;
@@ -341,7 +324,7 @@ declare module 'svelte' {
341324 * */
342325 export function hydrate < Props extends Record < string , any > , Exports extends Record < string , any > , Events extends Record < string , any > > ( component : ComponentType < SvelteComponent < Props , Events , any > > , options : {
343326 target : Document | Element | ShadowRoot ;
344- props ?: RemoveBindable < Props > | undefined ;
327+ props ?: Props | undefined ;
345328 events ?: { [ Property in keyof Events ] : ( e : Events [ Property ] ) => any ; } | undefined ;
346329 context ?: Map < any , any > | undefined ;
347330 intro ?: boolean | undefined ;
0 commit comments