我使用的是角4.0.0和类型记录2.2.1和datejs 1.0.0-rc3。每当我试图编译应用程序(npm )时,我都会得到以下类型记录错误:
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;有人知道发生了什么事吗?
发布于 2017-09-01 01:03:36
使用格式方法。博士:https://github.com/abritinthebay/datejs/wiki/Format-Specifiers
DateJs: IDateJSStatic = Date as any;
getDay() {
const day = new DateJs('2017-04-01')
return day.format('l')
}https://stackoverflow.com/questions/43044076
复制相似问题