Is there a way to import a JSON object into a Typescript program so that it is automatically strongly typed and constant?
So if I have this code in person.json:
{
"name": "Steven",
"eyeColor": "brown"
}
I want to be able to import it to a Typescript program as such:
// personTest.ts
const person = require('person.json');
console.log(person.name); // This should be fine
console.log(person.age); // This should cause a compile-time error, because this property is not defined
import person from 'person.json'