fix: enhance snapshot type handling for array structures in $state

pull/18110/head
Jungzl 5 months ago
parent 936d537611
commit 41dacc1dbf

@ -86,7 +86,13 @@ declare namespace $state {
: T extends { toJSON(): infer R }
? R
: T extends readonly unknown[]
? { [K in keyof T]: Snapshot<T[K]> }
? number extends T['length']
? T extends Array<infer U>
? Array<Snapshot<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<Snapshot<U>>
: never
: { [K in keyof T]: Snapshot<T[K]> }
: T extends Array<infer U>
? Array<Snapshot<U>>
: T extends object

@ -2203,10 +2203,10 @@ declare module 'svelte/motion' {
* const tween = Tween.of(() => number);
* </script>
* ```
*
*
*/
static of<U>(fn: () => U, options?: TweenOptions<U> | undefined): Tween<U>;
constructor(value: T, options?: TweenOptions<T>);
/**
* Sets `tween.target` to `value` and returns a `Promise` that resolves if and when `tween.current` catches up to it.
@ -2257,7 +2257,7 @@ declare module 'svelte/reactivity' {
* ```
*/
export class SvelteDate extends Date {
constructor(...params: any[]);
#private;
}
@ -2293,12 +2293,12 @@ declare module 'svelte/reactivity' {
* {#if monkeys.has('🙊')}<p>speak no evil</p>{/if}
* ```
*
*
*
*/
export class SvelteSet<T> extends Set<T> {
constructor(value?: Iterable<T> | null | undefined);
add(value: T): this;
#private;
}
@ -2344,12 +2344,12 @@ declare module 'svelte/reactivity' {
* {/if}
* ```
*
*
*
*/
export class SvelteMap<K, V> extends Map<K, V> {
constructor(value?: Iterable<readonly [K, V]> | null | undefined);
set(key: K, value: V): this;
#private;
}
@ -2412,7 +2412,7 @@ declare module 'svelte/reactivity' {
* ```
*/
export class SvelteURLSearchParams extends URLSearchParams {
[REPLACE](params: URLSearchParams): void;
#private;
}
@ -2488,7 +2488,7 @@ declare module 'svelte/reactivity' {
*/
export function createSubscriber(start: (update: () => void) => (() => void) | void): () => void;
class ReactiveValue<T> {
constructor(fn: () => T, onsubscribe: (update: () => void) => void);
get current(): T;
#private;
@ -2553,7 +2553,7 @@ declare module 'svelte/reactivity/window' {
get current(): number | undefined;
};
class ReactiveValue<T> {
constructor(fn: () => T, onsubscribe: (update: () => void) => void);
get current(): T;
#private;
@ -3284,7 +3284,13 @@ declare namespace $state {
: T extends { toJSON(): infer R }
? R
: T extends readonly unknown[]
? { [K in keyof T]: Snapshot<T[K]> }
? number extends T['length']
? T extends Array<infer U>
? Array<Snapshot<U>>
: T extends ReadonlyArray<infer U>
? ReadonlyArray<Snapshot<U>>
: never
: { [K in keyof T]: Snapshot<T[K]> }
: T extends Array<infer U>
? Array<Snapshot<U>>
: T extends object

Loading…
Cancel
Save