I am currently converting my project from ES5 to ES6, but I am running into an issue with MomentJS (version 2.18.1
). The problem is that I have a few variables that
Did you tried importing moment without alias?
import moment from 'moment';
This worked for me. And typescript compiler won't complain about it.
const date = moment().format('YYYYMMDD');
Note that this requires a tsconfig update!
In the TSConfig you need to add the option allowSyntheticDefaultImports to allow default imports of libraries that have no default exports.
Example (tsconfig.json):
{
"compileOnSave": false,
"compilerOptions": {
"allowSyntheticDefaultImports": true,
}
}