【发布时间】:2020-11-07 23:58:20
【问题描述】:
我正在尝试在我的数据属性中设置数组的类型,如下所示:
const Projects = defineComponent({
data: () => ({
issues: [] as IssueType[]
}),
我正在调用这个过滤数组的方法:
getIssues(projectId: number, label: string): [] {
return this.issues.filter(
issue => issue.project_id === projectId && issue.labels?.includes(label)
);
但是 Typescript 返回我以下错误:
> Type 'IssueType[]' is not assignable to type '[]'. Types of property
> 'length' are incompatible.
> Type 'number' is not assignable to type '0'.
【问题讨论】:
标签: typescript vue.js vuejs3