Allow checking json in conjunction with .d.json.ts files #52994
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
Suggestion
๐ Search Terms
checkJson, check json, .d.json.ts
โ Viability Checklist
My suggestion meets these guidelines:
โญ Suggestion
So in TS 5.0 we can add
.d.json.ts
files to type JSON files, i.e.:This is nice, but it would be better if we could validate that the corresponding
.json
files do in fact actually match the type. I'd like to propose a new option,checkJson
that when set validates types errors within JSON files.For example suppose we have:
Then TypeScript would report a type error when running
tsc
on the project (or in the editor).๐ Motivating Example
Pretty much anywhere manual JSON files are used in conjunction with
.d.json.ts
files would be useful. The point of TS is to help detect errors, extending this to JSON is a natural extension.In particular this would make a particularly good alternative to JSON schema support as I proposed in another issue.
The text was updated successfully, but these errors were encountered: