Skip to content

Commit f08aba0

Browse files
committed
more docs, fix type
1 parent 09617ba commit f08aba0

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

packages/svelte/src/index.d.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,17 @@ export interface ComponentConstructorOptions<
2121
$$inline?: boolean;
2222
}
2323

24-
/** Tooling for types uses this for properties that can only ever be bound to */
24+
/** Tooling for types uses this for properties are being used with `bind:` */
2525
export type Binding<T> = { 'bind:': T };
26-
/** Tooling for types uses this for properties that may be bound to */
26+
/**
27+
* Tooling for types uses this for properties that may be bound to.
28+
* Only use this if you author Svelte component type definition files by hand (we recommend using `@sveltejs/package` instead).
29+
* Example:
30+
* ```ts
31+
* export class MyComponent extends SvelteComponent<{ readonly: string, bindable: Bindable<string> }> {}
32+
* ```
33+
* means you can now do `<MyComponent {readonly} bind:bindable />`
34+
*/
2735
export type Bindable<T> = T | Binding<T>;
2836

2937
type WithBindings<T> = {
@@ -42,7 +50,7 @@ type PropsWithChildren<Props, Slots> = WithBindings<Props> &
4250
// signatures work (they will always take precedence and make an impossible-to-satisfy children type).
4351
Props extends Record<string, never>
4452
? any
45-
: { children: any }
53+
: { children?: any }
4654
: {});
4755

4856
/**

packages/svelte/types/index.d.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,17 @@ declare module 'svelte' {
1717
$$inline?: boolean;
1818
}
1919

20-
/** Tooling for types uses this for properties that can only ever be bound to */
20+
/** Tooling for types uses this for properties are being used with `bind:` */
2121
export type Binding<T> = { 'bind:': T };
22-
/** Tooling for types uses this for properties that may be bound to */
22+
/**
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+
*/
2331
export type Bindable<T> = T | Binding<T>;
2432

2533
type WithBindings<T> = {
@@ -38,7 +46,7 @@ declare module 'svelte' {
3846
// signatures work (they will always take precedence and make an impossible-to-satisfy children type).
3947
Props extends Record<string, never>
4048
? any
41-
: { children: any }
49+
: { children?: any }
4250
: {});
4351

4452
/**

0 commit comments

Comments
 (0)