简体   繁体   English

将矩距范围导入Angular 4.x应用程序(ES6)-没有兼容的呼叫签名错误?

[英]Importing moment-range into Angular 4.x application (ES6) - no compatible call signatures error?

I am trying to import the moment-range package into my Angular 4.x application the official documentation shows this :- 我正在尝试将矩程包导入到我的Angular 4.x应用程序中,官方文档显示如下:-

import Moment from 'moment';
import { extendMoment } from 'moment-range';
const moment = extendMoment(Moment);

However in my application moment has been added by the following method : 但是在我的应用程序时刻,已通过以下方法添加了:

import * as Moment from 'moment';

So I decided to use the same method to try and get moment-range to work 因此,我决定使用相同的方法来尝试确定工作范围

import * as Moment from 'moment';
import * as MomentRange from 'moment-range';
const moment = MomentRange(Moment);

However I am getting the following typescript error - can anyone suggest how I fix this? 但是我收到以下打字稿错误-有人可以建议我如何解决此错误吗?

Cannot invoke an expression whose type lacks a call signature. 
Type 'typeof "/node_modules/moment-range/dist/moment-range"' 
has no compatible call signatures.

Found this on github and it worked for me - hope it helps others 在github上找到了这个并且对我有用-希望它对其他人有帮助

import * as moment from 'moment';
import { extendMoment } from 'moment-range';

const { range } = extendMoment(moment);

const timeRange = range(moment.utc([2015, 0, 1]), moment.utc([2015, 5, 1]));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM