0

I want to get a "postType" Property from an interface defined like this

export interface PostType {
  postType: {
    title?: string;
    content?: string;
  };
}

The purpose I want to take out and use the "postType" Property is as follows

const fn = (post: Post) => {
  ...
}

I used "Pick" but this doesn't work.

export type Post = Pick<PostType, 'postType'>;

The reason I've configured the interface above is that PostType is actually a property that corresponds to another interface.

So I have to follow PostType's interface.

How can I do this?

0

1 Answer 1

2

If I understand correctly you want to do this: PostType["postType"]

Sign up to request clarification or add additional context in comments.

1 Comment

This is the correct answer but in the future please flag duplicates for closure rather than answering them.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.