I want to use MomentJS in my ReactNative component using TypeScript. My project is configured to pull in the library's d.ts file from the node_modules directory.
This is how I am importing the library and using it:
import * as moment from "moment";
const time = moment();
My typescript compiles but when I run the app ReactNative errors as so:
This is my tsconfig.json file:
{
"compilerOptions": {
"target": "es6",
"moduleResolution": "node",
"jsx": "react",
"outDir": "build/",
"sourceMap": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
If I change my tsconfig 'target' to es5 I have problems with a number of other modules.
I think it is related to this question but I am doing as suggested in that question's answer.