We use JSON files to configure some of our web applications and obviously mistakes are being made in field names etc.
Is it possible to validate the JSON file using a TypeScript definitions? Or should we migrate our configuration to other format?
We use both Intellij and VSCode for development.
Example definition:
interface AppConfig {
field1: number;
field2?: string;
field3: number[];
}
Example configuration:
{
"field": 1,
"field3": 2
}
Example validation result:
TS2322: Type '{ field: number; field3: number[]; }' is not assignable to type 'AppConfig'.
TS2322: Type 'number' is not assignable to type 'number[]'.