簡體   English   中英

類型 Posts[] 上不存在屬性查找

[英]property find does not exists on type Posts[]

我創建了以下界面:

export interface Post {
    _id: string;
    admin: Admin;
    comments: PostComment[];
    createdAt: Date;
    modified: boolean;
    text?: string;
    desc?: string;
    photoPath?: string;
}

但是當我使用這個時:

const post = posts.find((e: Post) => e._id === cmnt.postId);

它拋出錯誤,'屬性'find'在類型'Post []'上不存在..如何解決這個問題......

您需要在 tsconfig 中將編譯器target設置為 ES6。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM