I encountered issues with Typescript 3.* and momentjs when working with dates, resulting in compile time errors.
Error:(3, 13) TS2349: Cannot invoke an expression whose type lacks a call signature. Type 'typeof moment' has no compatible call signatures.
To address this error, I sought out a solution and came across an informative article detailing the steps to resolve it.
However, even after following the instructions outlined in the article, I still faced compile time errors.
Error:(1, 8) TS1192: Module '"/Users/hogehoge/Work/Work_Fork/hoge/node_modules/moment/moment"' has no default export.
Below are snippets from my tsconfig file and program code:
{
"compilerOptions": {
"moduleResolution": "node",
"skipLibCheck": false,
"target": "es5",
"module": "commonjs",
"lib": ["es2017", "dom"],
"experimentalDecorators": true,
"allowJs": false,
"jsx": "react",
"sourceMap": true,
"strict": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"esModuleInterop": true,
"removeComments": true,
"newLine": "LF",
"downlevelIteration": true,
"resolveJsonModule": true,
"allowSyntheticDefaultImports": false
},
"exclude": ["node_modules"]
}
import moment from 'moment';
console.log(moment().format('YYYY-MM-DD'))