Cannot invoke an expression whose type lacks a call signature, using moment
In your case, what you're importing there is everything the library exports as an object called moment
. This object obviously doesn't have a call signature as pointed out by the compiler.
According to the type definitions shipped with the library, the default export is the moment function that you're looking to use.
Therefore, changing your import to the following should work:
import moment from 'moment';
I had the same problem. And I solved the issue in two ways.
1)I set the value of esModuleInterop false under compilerOptions
"esModuleInterop": false
- The second way I changed the code
import * as _moment from 'moment';
to the following code
import _moment from "moment";
both options worked fine for my code.