我将Angular 4.0.0与Typescript 2.2.1和datejs 1.0.0-rc3一起使用。每当我尝试编译应用程序 ( npm start ) 时,都会收到以下打字稿错误:
ERROR in [at-loader] ./src/app/services/dates.service.ts:9:56
TS2339: Property 'getDay' does not exist on type 'number'.
编码:
/** dates.service.ts **/
import {Injectable} from "@angular/core";
@Injectable()
export class CalendarService {
DateJs: IDateJSStatic = <any>Date;
getDay() {
var day = this.DateJs.parse('2017-04-01').getDay();
return day;
}
}
查看文件node_modules/@types/datejs/index.d.ts
,函数的声明parse()
显然是Date:
/** Converts the specified string value into its JavaScript Date equivalent using culture-specific format information. */
parse(dateString: string): Date;
有人知道发生了什么吗?