bcherny/json-schema-to-typescript

Comparison with `json-schema-to-ts`

Jazcash opened this issue · 1 comments

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

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.