运营商' +'不能应用于类型' {}'和'数字'问

时间:2017-07-31 21:58:18

标签: javascript typescript sbt underscore.js

我使用TypeScript 2.4,sbt和下划线。 当我使用时。

this.userData.summaryMonth = _.reduce(this.userData.monthValues, (m, n) => m+n, 0);

我的界面

export interface IUserPlan {
    id: number,
    login: string,
    fullName: string,
    role: IUserPlanRole,
    month?: string[]
    monthValues?: number[],
    summaryDay?: 0,
    summaryMonth?: number,
    workingDays?: number,
    nonWorkingDays?: number,
    filterType: string
}

我收到错误:

[info] TypeScript compiling on 1 source(s)
[error] /developer/projects/------/app/assets/admin/statistics/statistics.controller.ts:220: Operator '+' cannot be applied to types 'number' and '{}'.
[error] this.userData.summaryMonth = _.reduce(this.userData.monthValues, (m, n) => m+n, 0);                                                                                                        
        ^
[error] one error found
[error] (bo/web-assets:typescript) com.typesafe.sbt.web.CompileProblemsException

0 个答案:

没有答案