Comparison with `json-schema-to-ts`
Jazcash opened this issue · 1 comments
Jazcash commented
What are the differences between this library and json-schema-to-ts?
aloisklink commented
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), thenjson-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, whilejson-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.- This will hopefully be fixed in the future by TypeScript, please upvote microsoft/TypeScript#32063 if you're interested!