I have a TypeScript (NodeJS-10.6.0) code and need to create a variable that will retrieve the contents of a JSON file.
I've tried to import the contents of the file in the following ways:
1. import { orderPayload } = require('../../events/qa/myfile.json');
2. import { orderPayload } = '../../events/qa/myfile.json';
3. const orderPayload: Order = require ('../../events/qa/myfile.json');
4. const orderPayload= require ('../../events/qa/myfile.json');
TSlint shows the following errors:
1. TS1141 - String Literal expected, Required statement not part of a import statement (no-var-required)
2. String Literal expected
3. Required statement not part of a import statement (no-var-required)
4. Required statement not part of a import statement (no-var-required)
Is there any way to import the contents of this JSON file into the orderPayload
variable without having to use the NodeJs FS file system module?