如何在接口或父类型中获取嵌套类型对象?
interface IFake {
button: {
height: {
dense: number;
standard: number;
};
};
otherStuff: string;
}
type Button = Pick<IFake, 'button'>
const aFunction = (button: Button) => button.height.dense
我得到的是
// Button type is {
// button: {
// height: ...
// }
// }
我想要什么:
// Button type is { height: ... }
答案 0 :(得分:2)
只要做
type Button = IFake["button"];