If i write the following type
type myType<T> = {
[K in keyof T]?: T[K] extends ({[k:string]: any} | undefined) ? T[K] : 0
}
when T[K] is an array of any type, myType behaves as if T[K] extends ({[k:string]:any)|undefined) was true even if any[] is not a {[k:string]:any}. So when i try to use this type like this i get an error:
declare class obj {
a?: string
b?: any[] // <-- if this gets changed to a primitive there is no more error
c?: {
d: number
}
}
const a: myType<obj> = {
a: 0,
b: 0, // <-- this gives an error
c: {
d: 1
}
}