Answer the question
In order to leave comments, you need to log in
How to infer type from interface part with nested structure?
Let's say I have an interface like this:
interface Book {
id: number,
author: {
name: string,
age: number,
},
price: {
value: number,
currency: Currency,
}
}
function doSomething(author: {name: string, age: number})
How can I automatically infer the type from the Book interface? I tried to do , but as a result I get , but I just need . {name: string, age: number}
Pick<Book, "author">
{author: {name: string, age: number}}
{name: string, age: number}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question