我想从这样定义的接口中获取“ postType”属性
export interface PostType {
postType: {
title?: string;
content?: string;
};
}
我要取出并使用“ postType”属性的目的如下
const fn = (post: Post) => {
...
}
我使用了“ Pick”,但这不起作用。
export type Post = Pick<PostType, 'postType'>;
我在上面配置接口的原因是PostType实际上是与另一个接口相对应的属性。
所以我必须遵循PostType的界面。
我该怎么做?
答案 0 :(得分:2)
如果我正确理解,您想这样做:PostType["postType"]