I created the following interface:
export interface Post {
_id: string;
admin: Admin;
comments: PostComment[];
createdAt: Date;
modified: boolean;
text?: string;
desc?: string;
photoPath?: string;
}
But when I used this:
const post = posts.find((e: Post) => e._id === cmnt.postId);
it throws error, 'Property 'find' does not exist on type 'Post[]'.. How to fix this...
You need to set your compiler target
to ES6 in tsconfig.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.