I\'m trying to learn Typescript. While I don\'t think it\'s relevant, I\'m using VSCode for this demo.
I have a package.json that has these pieces in it
I've just noticed that the answer that I upvoted and commented on is ambiguous. So the following is exactly what worked for me. I'm currently on Moment 2.26.0 and TS 3.8.3:
In code:
import moment from 'moment';
In TS config:
{
"compilerOptions": {
"esModuleInterop": true,
...
}
}
I am building for both CommonJS and EMS so this config is imported into other config files.
The insight comes from this answer which relates to using Express. I figured it was worth adding here though, to help anyone who searches in relation to Moment.js, rather than something more general.