I would like to implement deep pick in typescript.
My example code is:
interface TestBook {
id: string;
name: string;
}
interface TestUser {
id: string;
email: string;
books: TestBook[];
}
I and I would like to use deep pick like:
const foo: DeepPick<TestUser, 'id' | 'books.name'> = {...
/*
{
id: ..
books: [{name: ...}]
}
*/
Problem: There is only Pick
in standard typescript and there is no library implement this DeepPick
.
How can I do it? Which technic should I use?
I tried to find on google and SO.
'books.[].id'
but I need to usebooks.id
– Pshaw