代码:- 1.部门:部门[];
let sectionCount:number;
sectionCount = +this.sections.find(x =>x.sections).sections;
错误。
error TS2345: Argument of type '(this: void, x: Departments) => number' is not assignable to parameter of type '(value: Departments, index: number, obj: Departments[]) => boolean'.
Type 'number' is not assignable to type 'boolean'.
答案 0 :(得分:1)
如果您是根据错误Type 'number' is not assignable to type 'boolean'
进行解释,则与sectionCount
无关。
如错误所述,find()方法必须返回布尔值而不是数字-
尝试类似-
sectionCount = this.sections.find(x => {
return x.sections > 0;
}).sections;