ts-transform-json-schema (v2.0.3) is a TypeScript custom transformer that generates inline JSON Schema from TypeScript interfaces and types at compile time. It replaces type annotations with actual schema objects, eliminating the need for runtime reflection. The library integrates with TTypeScript and supports schema options like additionalProperties. It is maintained sparsely, with the latest version from February 2021. Key differentiators: compile-time transformation vs runtime generators, zero runtime cost, and direct TypeScript type source of truth.
npm install ts-transform-json-schemaNo compatibility data collected yet for this library.
Verified import paths — ran on the pinned version, not inferred.
Configures TTypeScript and demonstrates compile-time JSON Schema generation from a TypeScript interface.
Install and use ttypescript: npm install ttypescript --save-dev and run ttsc instead of tsc.
Stick to simple interfaces and type aliases. Test generated schema for complex types.
Update calls from fromType<SomeInterface>(false) to fromType<SomeInterface>({ additionalProperties: false })No fix; library does not support other drafts. Consider alternatives if newer draft required.
Add ts-transform-json-schema to compilerOptions.plugins in tsconfig.json and use ttsc.
Use ttsc command from ttypescript package: npx ttsc
Run npm install ts-transform-json-schema --save-dev and ensure tsconfig.json has the plugin entry.