I am creating a generic type DeepPick so it can create new sub types while giving intellisense to users
interface User {
emailAddress: string;
verification: {
verified: boolean;
verificationCode: string;
}
activeApps: {
name: string,
size: number,
stars: 1 | 2 | 3 | 4 | 5,
developers: string[],
downloads: number
}[];
}
type DeepPartial<T> = {
[P in keyof T]?: T[P] extends Array<infer U>
? Array<DeepPartial<U>>
: T[P] extends ReadonlyArray<infer U>
? ReadonlyArray<DeepPartial<U>>
: DeepPartial<T[P]>
}
type DeepPick<U, T extends DeepPartial<U>> = T
const newUser = {} as DeepPick<User, {
activeApps: {
// Need intellisense here to give name, size, stars, developers and downloads
}[],
}>
it does give intellisense while typing non array fields like email, verification. and also inside verification. but it is not giving inside activeApps which is a array.