So the code is simple:
calls.json
{\"SERVER\":{
\"requests\":{
\"one\":\"1\"
}
} }
file.ts
import jso
TS 2.9 added support for well typed json imports. Just add:
{
"compilerOptions": {
"resolveJsonModule": true
}
}
in your tsconfig.json or jsconfig.json. Now imports such as:
import json = require('../static/calls.json');
and
import * as json from '../static/calls.json';
should be resolved and have proper typings too!