fix: ts 错误: 类型实例化过深,且可能无限

pull/332/head^2
moil-xm 2026-02-10 16:13:36 +08:00 committed by GitHub
parent aace726a91
commit 7fe8d7b4be
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 26 additions and 8 deletions

View File

@ -1,20 +1,38 @@
import type { ComputedRef, MaybeRef } from 'vue';
/**
*
*/
type Increment<A extends unknown[]> = [...A, unknown];
/**
*
*/
type DeepPartial<T> = T extends object
? {
[P in keyof T]?: DeepPartial<T[P]>;
}
: T;
type DeepPartial<
T,
D extends number = 10,
C extends unknown[] = [],
> = C['length'] extends D
? T
: T extends object
? {
[P in keyof T]?: DeepPartial<T[P], D, Increment<C>>;
}
: T;
/**
*
*/
type DeepReadonly<T> = {
readonly [P in keyof T]: T[P] extends object ? DeepReadonly<T[P]> : T[P];
};
type DeepReadonly<
T,
D extends number = 10,
C extends unknown[] = [],
> = C['length'] extends D
? T
: T extends object
? {
readonly [P in keyof T]: DeepReadonly<T[P], D, Increment<C>>;
}
: T;
/**
*