I recently came across the jsondata.json
file:
{
"name": "John",
"age": 30,
"car": "ferrari"
}
Located in the same directory is a typescript file called main.ts
where I simply output the json data using console.log
import * as j from './jsondata.json';
console.log(j);
The output includes an unexpected field named default
. What is this field, why does it appear, and how can it be removed?
Just for your information, here is my setup in the tsconfig.json
:
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"sourceMap": true,
"outDir": "./out",
"strict": true,
"moduleResolution": "node",
"esModuleInterop": true,
"resolveJsonModule": true,
"forceConsistentCasingInFileNames": true
}
}