type ExtractGenerics<T extends readonly unknown[]> = T extends readonly []
? []
: T extends readonly [G<infer V>, ...infer Next]
? [V, ...ExtractGenerics<Next>]
: T extends readonly (G<infer V>)[]
? V[]
: never;
type Input2 = G<number>[]
const values3 = unwrap([ // = number[]
{ value: 1 },
] as Input2)
VSCode это и не IDE по-хорошему-то.
type TTT<T> = T extends infer U ? [U] : -1
type ttt11 = TTT<'a' | 'b'> // type ttt11 = ["a"] | ["b"]
type ttt12 = 'a' | 'b' extends infer U ? [U] : -1 // type ttt12 = ["a" | "b"]
то на чем будет спотыкаться?
получается, в твоем UnionToIntersection внешний extends не считает выражение слева как объединение и не делает цикл по нему? какова его природа?
Normalizer<{
completed: boolean;
} & {
readonly title: string;
readonly description: string;
}>
type Normalizer<T> = {
[Key in keyof T]: T[Key]
} & {}
type MyReadonly<T, K extends keyof T> = Normalizer<{
readonly [Key in K]: T[Key]
} & {
[Key in Exclude<keyof T, K>]: T[Key]
}>
type MyRO = MyReadonly<Todo, 'title' | 'description'>;
/*
type MyRO = {
readonly title: string;
readonly description: string;
completed: boolean;
}
*/