I noticed that some json files with specific names get intellisense, like:
tsconfig.jsonjsconfig.jsonpackage.json.eslintrc.json.prettierrc.json
Some screenchots
[
]
[
]
how can i type the schema of my own json files is it declares as a json module or something similar?
CodePudding user response:
just create a person.model.ts file that carries your json interface then export the interface from the file in which is defined
interface Person{
name: string;
age: number;
}
then import it wherever you want to use it
import Person from "./person.model.ts"
then use it as a type for your json
let p:Person = {
name: 'Joe',
age: 20
}
also your editor/IDE will guide you with the missing types and will throw an error if you entered a wrong property like that

CodePudding user response:

