-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
svelte-shims.d.ts
261 lines (224 loc) · 12.3 KB
/
svelte-shims.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
// Whenever a ambient declaration changes, its number should be increased
// This way, we avoid the situation where multiple ambient versions of svelte2tsx
// are loaded and their declarations conflict each other
// See https://github.com/sveltejs/language-tools/issues/1059 for an example bug that stems from it
declare module '*.svelte' {
export default Svelte2TsxComponent
}
declare class Svelte2TsxComponent<
Props extends {} = {},
Events extends {} = {},
Slots extends {} = {}
> {
// svelte2tsx-specific
/**
* @internal This is for type checking capabilities only
* and does not exist at runtime. Don't use this property.
*/
$$prop_def: Props;
/**
* @internal This is for type checking capabilities only
* and does not exist at runtime. Don't use this property.
*/
$$events_def: Events;
/**
* @internal This is for type checking capabilities only
* and does not exist at runtime. Don't use this property.
*/
$$slot_def: Slots;
// https://svelte.dev/docs#Client-side_component_API
constructor(options: Svelte2TsxComponentConstructorParameters<Props>);
/**
* Causes the callback function to be called whenever the component dispatches an event.
* A function is returned that will remove the event listener when called.
*/
$on<K extends keyof Events & string>(event: K, handler: (e: Events[K]) => any): () => void;
/**
* Removes a component from the DOM and triggers any `onDestroy` handlers.
*/
$destroy(): void;
/**
* Programmatically sets props on an instance.
* `component.$set({ x: 1 })` is equivalent to `x = 1` inside the component's `<script>` block.
* Calling this method schedules an update for the next microtask — the DOM is __not__ updated synchronously.
*/
$set(props?: Partial<Props>): void;
// From SvelteComponent(Dev) definition
$$: any;
$capture_state(): void;
$inject_state(): void;
}
interface Svelte2TsxComponentConstructorParameters<Props extends {}> {
/**
* An HTMLElement to render to. This option is required.
*/
target: Element | ShadowRoot;
/**
* A child of `target` to render the component immediately before.
*/
anchor?: Element;
/**
* An object of properties to supply to the component.
*/
props?: Props;
context?: Map<any, any>;
hydrate?: boolean;
intro?: boolean;
$$inline?: boolean;
}
type AConstructorTypeOf<T, U extends any[] = any[]> = new (...args: U) => T;
type SvelteComponentConstructor<T, U extends Svelte2TsxComponentConstructorParameters<any>> = new (options: U) => T;
type SvelteActionReturnType = {
update?: (args: any) => void,
destroy?: () => void
} | void
type SvelteTransitionConfig = {
delay?: number,
duration?: number,
easing?: (t: number) => number,
css?: (t: number, u: number) => string,
tick?: (t: number, u: number) => void
}
type SvelteTransitionReturnType = SvelteTransitionConfig | (() => SvelteTransitionConfig)
type SvelteAnimationReturnType = {
delay?: number,
duration?: number,
easing?: (t: number) => number,
css?: (t: number, u: number) => string,
tick?: (t: number, u: number) => void
}
type SvelteWithOptionalProps<Props, Keys extends keyof Props> = Omit<Props, Keys> & Partial<Pick<Props, Keys>>;
type SvelteAllProps = { [index: string]: any }
type SveltePropsAnyFallback<Props> = {[K in keyof Props]: Props[K] extends undefined ? any : Props[K]}
type SvelteSlotsAnyFallback<Slots> = {[K in keyof Slots]: {[S in keyof Slots[K]]: Slots[K][S] extends undefined ? any : Slots[K][S]}}
type SvelteRestProps = { [index: string]: any }
type SvelteSlots = { [index: string]: any }
type SvelteStore<T> = { subscribe: (run: (value: T) => any, invalidate?: any) => any }
// Forces TypeScript to look into the type which results in a better representation of it
// which helps for error messages and is necessary for d.ts file transformation so that
// no ambient type references are left in the output
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never;
type KeysMatching<Obj, V> = {[K in keyof Obj]-?: Obj[K] extends V ? K : never}[keyof Obj]
declare type __sveltets_1_CustomEvents<T> = {[K in KeysMatching<T, CustomEvent>]: T[K] extends CustomEvent ? T[K]['detail']: T[K]}
declare var process: NodeJS.Process & { browser: boolean }
declare var __sveltets_1_AnimationMove: { from: DOMRect, to: DOMRect }
declare function __sveltets_1_ensureAnimation(animationCall: SvelteAnimationReturnType): {};
declare function __sveltets_1_ensureAction(actionCall: SvelteActionReturnType): {};
declare function __sveltets_1_ensureTransition(transitionCall: SvelteTransitionReturnType): {};
declare function __sveltets_1_ensureFunction(expression: (e: Event & { detail?: any }) => unknown ): {};
declare function __sveltets_1_ensureType<T>(type: AConstructorTypeOf<T>, el: T): {};
declare function __sveltets_1_ensureType<T1, T2>(type1: AConstructorTypeOf<T1>, type2: AConstructorTypeOf<T2>, el: T1 | T2): {};
declare function __sveltets_1_createEnsureSlot<Slots = Record<string, Record<string, any>>>(): <K1 extends keyof Slots, K2 extends keyof Slots[K1]>(k1: K1, k2: K2, val: Slots[K1][K2]) => Slots[K1][K2];
declare function __sveltets_1_ensureRightProps<Props>(props: Props): {};
declare function __sveltets_1_cssProp(prop: Record<string, any>): {};
declare function __sveltets_1_ctorOf<T>(type: T): AConstructorTypeOf<T>;
declare function __sveltets_1_instanceOf<T = any>(type: AConstructorTypeOf<T>): T;
declare function __sveltets_1_allPropsType(): SvelteAllProps
declare function __sveltets_1_restPropsType(): SvelteRestProps
declare function __sveltets_1_slotsType<Slots, Key extends keyof Slots>(slots: Slots): Record<Key, boolean>;
// Overload of the following two functions is necessary.
// An empty array of optionalProps makes OptionalProps type any, which means we lose the prop typing.
// optionalProps need to be first or its type cannot be infered correctly.
declare function __sveltets_1_partial<Props = {}, Events = {}, Slots = {}>(
render: {props: Props, events: Events, slots: Slots }
): {props: Expand<SveltePropsAnyFallback<Props>>, events: Events, slots: Expand<SvelteSlotsAnyFallback<Slots>> }
declare function __sveltets_1_partial<Props = {}, Events = {}, Slots = {}, OptionalProps extends keyof Props = any>(
optionalProps: OptionalProps[],
render: {props: Props, events: Events, slots: Slots }
): {props: Expand<SvelteWithOptionalProps<SveltePropsAnyFallback<Props>, OptionalProps>>, events: Events, slots: Expand<SvelteSlotsAnyFallback<Slots>> }
declare function __sveltets_1_partial_with_any<Props = {}, Events = {}, Slots = {}>(
render: {props: Props, events: Events, slots: Slots }
): {props: Expand<SveltePropsAnyFallback<Props> & SvelteAllProps>, events: Events, slots: Expand<SvelteSlotsAnyFallback<Slots>> }
declare function __sveltets_1_partial_with_any<Props = {}, Events = {}, Slots = {}, OptionalProps extends keyof Props = any>(
optionalProps: OptionalProps[],
render: {props: Props, events: Events, slots: Slots }
): {props: Expand<SvelteWithOptionalProps<SveltePropsAnyFallback<Props>, OptionalProps> & SvelteAllProps>, events: Events, slots: Expand<SvelteSlotsAnyFallback<Slots>> }
declare function __sveltets_1_with_any<Props = {}, Events = {}, Slots = {}>(
render: {props: Props, events: Events, slots: Slots }
): {props: Expand<Props & SvelteAllProps>, events: Events, slots: Slots }
declare function __sveltets_1_with_any_event<Props = {}, Events = {}, Slots = {}>(
render: {props: Props, events: Events, slots: Slots }
): {props: Props, events: Events & {[evt: string]: CustomEvent<any>;}, slots: Slots }
declare function __sveltets_1_store_get<T = any>(store: SvelteStore<T>): T
declare function __sveltets_1_store_get<Store extends SvelteStore<any> | undefined | null>(store: Store): Store extends SvelteStore<infer T> ? T : Store;
declare function __sveltets_1_any(dummy: any): any;
declare function __sveltets_1_empty(...dummy: any[]): {};
declare function __sveltets_1_componentType(): AConstructorTypeOf<Svelte2TsxComponent<any, any, any>>
declare function __sveltets_1_invalidate<T>(getValue: () => T): T
declare function __sveltets_1_mapWindowEvent<K extends keyof HTMLBodyElementEventMap>(
event: K
): HTMLBodyElementEventMap[K];
declare function __sveltets_1_mapBodyEvent<K extends keyof WindowEventMap>(
event: K
): WindowEventMap[K];
declare function __sveltets_1_mapElementEvent<K extends keyof HTMLElementEventMap>(
event: K
): HTMLElementEventMap[K];
declare function __sveltets_1_mapElementTag<K extends keyof ElementTagNameMap>(
tag: K
): ElementTagNameMap[K];
declare function __sveltets_1_mapElementTag<K extends keyof SVGElementTagNameMap>(
tag: K
): SVGElementTagNameMap[K];
declare function __sveltets_1_mapElementTag(
tag: any
): HTMLElement;
declare function __sveltets_1_bubbleEventDef<Events, K extends keyof Events>(
events: Events, eventKey: K
): Events[K];
declare function __sveltets_1_bubbleEventDef(
events: any, eventKey: string
): any;
declare const __sveltets_1_customEvent: CustomEvent<any>;
declare function __sveltets_1_toEventTypings<Typings>(): {[Key in keyof Typings]: CustomEvent<Typings[Key]>};
declare function __sveltets_1_unionType<T1, T2>(t1: T1, t2: T2): T1 | T2;
declare function __sveltets_1_unionType<T1, T2, T3>(t1: T1, t2: T2, t3: T3): T1 | T2 | T3;
declare function __sveltets_1_unionType<T1, T2, T3, T4>(t1: T1, t2: T2, t3: T3, t4: T4): T1 | T2 | T3 | T4;
declare function __sveltets_1_unionType(...types: any[]): any;
declare function __sveltets_1_awaitThen<T>(
promise: T,
onfulfilled: (value: T extends PromiseLike<infer U> ? U : T) => any,
onrejected?: (value: T extends PromiseLike<any> ? any : never) => any
): any;
declare function __sveltets_1_each<T extends ArrayLike<unknown>>(
array: T,
callbackfn: (value: T extends ArrayLike<infer U> ? U : any, index: number) => any
): any;
declare function __sveltets_1_createSvelte2TsxComponent<Props, Events, Slots>(
render: {props: Props, events: Events, slots: Slots }
): SvelteComponentConstructor<Svelte2TsxComponent<Props, Events, Slots>,Svelte2TsxComponentConstructorParameters<Props>>;
declare function __sveltets_1_unwrapArr<T>(arr: ArrayLike<T>): T
declare function __sveltets_1_unwrapPromiseLike<T>(promise: PromiseLike<T> | T): T
// v2
declare function __sveltets_2_createCreateSlot<Slots = Record<string, Record<string, any>>>(): <SlotName extends keyof Slots>(slotName: SlotName, attrs: Slots[SlotName]) => Record<string, any>;
declare function __sveltets_2_createComponentAny(props: Record<string, any>): Svelte2TsxComponent<any, any, any>;
declare function __sveltets_2_any(...dummy: any[]): any;
declare function __sveltets_2_empty(...dummy: any[]): {};
declare function __sveltets_2_cssProp(prop: Record<string, any>): {};
type __sveltets_2_SvelteAnimationReturnType = {
delay?: number,
duration?: number,
easing?: (t: number) => number,
css?: (t: number, u: number) => string,
tick?: (t: number, u: number) => void
}
declare var __sveltets_2_AnimationMove: { from: DOMRect, to: DOMRect }
declare function __sveltets_2_ensureAnimation(animationCall: __sveltets_2_SvelteAnimationReturnType): {};
type __sveltets_2_SvelteActionReturnType = {
update?: (args: any) => void,
destroy?: () => void
} | void
declare function __sveltets_2_ensureAction(actionCall: __sveltets_2_SvelteActionReturnType): {};
type __sveltets_2_SvelteTransitionConfig = {
delay?: number,
duration?: number,
easing?: (t: number) => number,
css?: (t: number, u: number) => string,
tick?: (t: number, u: number) => void
}
type __sveltets_2_SvelteTransitionReturnType = __sveltets_2_SvelteTransitionConfig | (() => __sveltets_2_SvelteTransitionConfig)
declare function __sveltets_2_ensureTransition(transitionCall: __sveltets_2_SvelteTransitionReturnType): {};
declare function __sveltets_2_ensureType<T>(type: AConstructorTypeOf<T>, el: T): {};
declare function __sveltets_2_ensureType<T1, T2>(type1: AConstructorTypeOf<T1>, type2: AConstructorTypeOf<T2>, el: T1 | T2): {};
declare function __sveltets_2_ensureComponent<T extends new (args: {target: any, props?: any}) => Svelte2TsxComponent<any, {}, any>>(type: T): T extends never ? Svelte2TsxComponent<any, any, any> : T;
declare function __sveltets_2_ensureArray<T extends ArrayLike<unknown>>(array: T): T extends ArrayLike<infer U> ? U[] : any[];