Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to properly import MomentJS in Typescript to resolve the following error: "Type 'typeof moment' has no compatible call signatures." [duplicate]

Importing MomentJS is causing the following error:

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

How can I resolve this error?

like image 328
Lindauson Avatar asked Oct 25 '25 16:10

Lindauson


1 Answers

The latest version of MomentJS now has defined types. Reinstall MomentJS without external typings. You should also avoid namespace-style import as such imports cannot be called or constructed and would cause a failure at runtime.

The way to go is traditional import:

import moment from 'moment';

like image 140
Lindauson Avatar answered Oct 28 '25 07:10

Lindauson