How do I define the type for imported json? For example
{
"things": "foo"
}
interface Data {
things: String,
another?: String
}
import data from './data.json' // Should have type Data
console.log(data.things)
console.log(data.another) // Should be allowed but undefined
The resolveJsonModule option will automatically generate types for the imported JSON but it is incomplete as the JSON may not contain all the possible fields for the data.
How do I define the type myself?