This package facilitates the automatic conversion of JSON Schema definitions into TypeScript interfaces and types. It is currently at version 0.14.3 and appears to be actively maintained, with its last publish occurring four days ago as of the current date, indicating a relatively frequent release cadence. A key differentiator is its robust handling of standard JSON Schema features like `$ref` and `$defs` for modular schema definitions, and its ability to process arrays of defined types seamlessly into TypeScript arrays. Unlike some alternative tools that focus on generating JSON Schema *from* TypeScript code, this library specifically targets the generation of TypeScript *from* existing JSON Schema, providing a critical tool for schema-first development workflows. It operates with minimal dependencies and is part of the broader `constructive-io/dev-utils` monorepo, although it is designed for general-purpose use.
npm install schema-typescriptVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import the `generateTypeScript` function and convert a sample JSON Schema object for a 'User' into a TypeScript interface string, then write it to a file.
Always pin to exact patch versions (`~0.14.3` instead of `^0.14.3`) in `package.json` and consult release notes before upgrading to a new minor version.
Test the conversion with representative complex schemas. For critical or edge-case schemas, consider simplifying the JSON Schema or manually adjusting the generated TypeScript definitions. Report specific issues to the maintainers.
Refer to the GitHub repository for `constructive-io/dev-utils` for the latest context and any ecosystem-specific guidelines if encountering unexpected behavior in complex integrations.
Ensure you are using `import { generateTypeScript } from 'schema-typescript';` in an ESM-compatible environment (e.g., Node.js with `"type": "module"` in `package.json` or a bundler configured for ESM).Validate your JSON Schema against the JSON Schema specification (e.g., using `ajv` or an online validator) before passing it to the function. Ensure all required fields like `type` are present and correctly formatted.
Verify that all `$ref` pointers are correct and that the referenced schemas are accessible. For external `$ref`s, ensure they are correctly provided to the library if it supports such options, or pre-resolve them if necessary.
No dependency data recorded yet.