如何在 Typescript 中正确导入 MomentJS 以解决以下错误:"Type 'typeof moment' has no compatible call signatures."



导入MONMJS正在引起以下错误:

ERROR in [...] Cannot invoke an expression whose type lacks a call signature. Type 'typeof moment' has no compatible call signatures.

如何解决此错误?

MOMMJS的最新版本现在已定义类型。重新安装Momentjs没有外部打字。您还应该避免命名空间式导入,因为无法调用或构造此类导入,并在运行时会导致故障。

要走的方式是传统的导入:

import moment from 'moment';

相关内容

最新更新