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 } : T extends { toJSON(): infer R }
? R ? R
: T extends readonly unknown[] : 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> : T extends Array<infer U>
? Array<Snapshot<U>> ? Array<Snapshot<U>>
: T extends object : T extends object

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

Loading…
Cancel
Save