Consider using '--resolveJsonModule' to import module with '.json' extensio code example
Example 1: Consider using '--resolveJsonModule
add "resolveJsonModule": true key in tsconfig.json
{
"compilerOptions": {
"target": "es2015",
"module": "commonjs",
"strict": true,
"moduleResolution": "node",
"resolveJsonModule": true
}
}
Example 2: read json file in typescript
{
"greeting" : "xin chao Vietnam"
}
import * as data from 'data.json';
let greeting = data.greeting;
"compilerOptions": {
....
"resolveJsonModule": true,
....
},