Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comparison with json-schema-to-ts #533

Open
Jazcash opened this issue Jun 27, 2023 · 1 comment
Open

Comparison with json-schema-to-ts #533

Jazcash opened this issue Jun 27, 2023 · 1 comment

Comments

@Jazcash
Copy link

Jazcash commented Jun 27, 2023

What are the differences between this library and json-schema-to-ts?

@aloisklink
Copy link
Contributor

Taken from the json-schema-to-ts README.md:

If you prefer to stick to them and can define your schemas in TS instead of JSON (importing JSONs as const is not available yet), then json-schema-to-ts is made for you

Basically, json-schema-to-ts operates fully in TypeScript!! This is very very cool, since, this means you don't need a separate npx json-schema-to-typescript build step to compile a .schema.json file into a .ts schema TypeScript file, then a typescript step. Instead, everything runs directly from TypeScript!!!

However, this has the following downsides, which makes json-schema-to-typescript better in some cases:

  • json-schema-to-typescript only needs to run once, while json-schema-to-ts will need to run every time you (or any user of your library) runs TypeScripts, which is much much slower.
  • No TSDoc comments are generated in json-schema-to-ts, since it's pure TypeScript.
  • Important: json-schema-to-ts only works with JSON Schema defined in a TypeScript file. Importing JSON schema from a .json file is not supported due to limitations in TypeScript.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants