Typescript Interface vs

我试图给我的mongoose文件分配一个文章数组,但似乎Typescript不喜欢,我不知道为什么它显示这个警告/错误,它是不可分配的。

我的mongoose模式和接口(简体):

 interface Profile { username: string, articles: [Article] } interface Article { index: number, name: string, } // Mongoose model export interface IProfile extends Profile, Document { } const Article = new Schema({ index: { type: Number, required: true }, name: { type: String, required: true }, }, { _id: false }) const Profile = new Schema({ username: { type: String, index: true }, upcomingChests: { type: [Article] }, }, { timestamps: true }) export const Profile = model<IProfileModel>('IProfile', Profile) 

我的代码试图分配文章:

 const profile: Profile = values[0] const articles: Array<Article> = values[1] profile.articles = articles // Error/Warning pops up in this line 

[ts]types“文章[]”不能用于键入“[Article]”。
属性“0”在“Article []”types中缺失。

我的问题:

为什么说这是不可转让的,[Article]和Article []之间有什么区别呢?

[Article]意味着不同的东西:一个元组元素的元组types。

您可能想使用Article[] Array<Article> ,types相同的Array<Article>