GOBL typescript types auto-generation #587
Unanswered
tom2strobl
asked this question in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hey there!
we call the backend from typescript and want to have type-safety on our end when constructing GOBL json in development, so we need transformation from the json schemas to types. While there is prior art in json-schema-to-ts & json-schema-to-typescript, both libraries were a little overchallenged by GOBLs complexity and self-references.
So I wrote a vanilla nodejs script without dependencies that cleanly transforms the json schemas in
gobl/data/schemas
to a singulartypes.ts
file to be picked up. We installed the gobl repo as a submodule and update it like so:git submodule update --remote --merge gobl && node scripts/generate-types.js
Here's the code: https://gist.github.com/tom2strobl/708b15dd3bf997115c245281f052a7e4
Feel free to add it to the repo or tell me where in the repo to put it in a PR.
Cheers,
Tom
Beta Was this translation helpful? Give feedback.
All reactions