{"id":25809,"library":"json-lint-d-ts","title":"json-lint-d-ts","description":"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.","status":"active","version":"1.2.2","language":"javascript","source_language":"en","source_url":"ssh://git@github.com/vlashchanka/json-lint-d-ts","tags":["javascript","configs","config","configuration","scheme","schema","json","json-schema","json-scheme","typescript"],"install":[{"cmd":"npm install json-lint-d-ts","lang":"bash","label":"npm"},{"cmd":"yarn add json-lint-d-ts","lang":"bash","label":"yarn"},{"cmd":"pnpm add json-lint-d-ts","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used for type checking JSON against .d.ts files during validation","package":"typescript","optional":true},{"reason":"Used for generating TypeScript declarations from JSON samples","package":"quicktype","optional":true}],"imports":[{"note":"ESM default; CommonJS require works but destructuring is not supported directly.","wrong":"const validate = require(\"json-lint-d-ts\").validate;","symbol":"validate","correct":"import { validate } from \"json-lint-d-ts\";"},{"note":"Both validate and generate are top-level exports.","wrong":"import { generate } from \"json-lint-d-ts/generate\";","symbol":"generate","correct":"import { generate } from \"json-lint-d-ts\";"},{"note":"Available since v1.2.0 for HTTP-based generation.","wrong":"import { generateAsync } from \"json-lint-d-ts/src/generateAsync\";","symbol":"generateAsync","correct":"import { generateAsync } from \"json-lint-d-ts\";"}],"quickstart":{"code":"import { validate } from \"json-lint-d-ts\";\n\nconst result = validate([\n  [\"./hello.json\", \"./hello.d.ts\"],\n]);\n\n// Result shows any type errors\nconsole.log(result);","lang":"typescript","description":"Validates a JSON file against a TypeScript declaration file using the validate function."},"warnings":[{"fix":"Ensure your .d.ts file exports a type named Root. For example: type Root = YourInterface;","message":".d.ts file must define a 'type Root' for validation to work; otherwise validation may silently succeed or fail unexpectedly.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Monitor quicktype changelog for breaking changes, or pin quicktype version if needed.","message":"generate function uses quicktype under the hood and may have breaking changes when quicktype updates.","severity":"deprecated","affected_versions":">=1.1.0"},{"fix":"Use string matching or regex to extract error details; consider wrapping validate in a custom parser.","message":"Validation errors are returned as strings, not structured objects. Parsing error messages for programmatic use is brittle.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Pre-fetch data with your own fetch() and pass the JSON body directly to generate.","message":"generateAsync does not support Bearer tokens or custom headers for HTTP endpoints; only raw URL fetch without authentication.","severity":"gotcha","affected_versions":">=1.2.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Install quicktype as a peer dependency: yarn add -D quicktype","cause":"Missing or incompatible quicktype version when using generate.","error":"TypeError: Cannot read properties of undefined (reading 'Symbol(quick-type)')"},{"fix":"Add `type Root = YourMainType;` to the declaration file.","cause":"The .d.ts file does not define a type named Root.","error":"Error: No type Root found in declaration file."},{"fix":"Use result = validate([...]) without await; validate returns an array directly.","cause":"Treating validate as async when it is synchronous.","error":"TypeError: validate(...).then is not a function"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}