Looking to incorporate MomentJS into my ReactNative component with TypeScript. Successfully imported the library's d.ts file from the node_modules directory.
This is how I am importing and utilizing the library:
import * as moment from "moment";
const time = moment();
Although my TypeScript compiles without errors, running the ReactNative app triggers the following error:
https://i.sstatic.net/CTqEI.png
Here's a glimpse into my tsconfig.json file:
{
"compilerOptions": {
"target": "es6",
"moduleResolution": "node",
"jsx": "react",
"outDir": "build/",
"sourceMap": true,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
}
}
Switching the 'target' in tsconfig to es5 causes issues with other modules.
Seems to be a similar issue to this query, but already following the suggested approach from the answer.