Lint JSON files against TypeScript declaration files. Current stable version is 1.2.2, released optionally. It validates JSON files by comparing them to .d.ts definitions, ensuring type safety without running TypeScript. Supports generation of .d.ts files from JSON samples (via quicktype) and from HTTP endpoints. Key differentiator: unlike JSON Schema validators, it uses TypeScript type definitions directly as the schema source.
npm install json-lint-d-tsNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Validates a JSON file against a TypeScript declaration file using the validate function.
Ensure your .d.ts file exports a type named Root. For example: type Root = YourInterface;
Monitor quicktype changelog for breaking changes, or pin quicktype version if needed.
Use string matching or regex to extract error details; consider wrapping validate in a custom parser.
Pre-fetch data with your own fetch() and pass the JSON body directly to generate.
Install quicktype as a peer dependency: yarn add -D quicktype
Add `type Root = YourMainType;` to the declaration file.
Use result = validate([...]) without await; validate returns an array directly.