File tree Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Expand file tree Collapse file tree 2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -21,9 +21,17 @@ export interface ComponentConstructorOptions<
21
21
$$inline ?: boolean ;
22
22
}
23
23
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:` */
25
25
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
+ */
27
35
export type Bindable < T > = T | Binding < T > ;
28
36
29
37
type WithBindings < T > = {
@@ -42,7 +50,7 @@ type PropsWithChildren<Props, Slots> = WithBindings<Props> &
42
50
// signatures work (they will always take precedence and make an impossible-to-satisfy children type).
43
51
Props extends Record < string , never >
44
52
? any
45
- : { children : any }
53
+ : { children ? : any }
46
54
: { } ) ;
47
55
48
56
/**
Original file line number Diff line number Diff line change @@ -17,9 +17,17 @@ declare module 'svelte' {
17
17
$$inline ?: boolean ;
18
18
}
19
19
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:` */
21
21
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
+ */
23
31
export type Bindable < T > = T | Binding < T > ;
24
32
25
33
type WithBindings < T > = {
@@ -38,7 +46,7 @@ declare module 'svelte' {
38
46
// signatures work (they will always take precedence and make an impossible-to-satisfy children type).
39
47
Props extends Record < string , never >
40
48
? any
41
- : { children : any }
49
+ : { children ? : any }
42
50
: { } ) ;
43
51
44
52
/**
You can’t perform that action at this time.
0 commit comments