xddq / schema2typebox

Creating TypeBox code from JSON schemas
MIT License
54 stars 12 forks source link

feature: add JavaScript codegen #41

Open croconut opened 3 months ago

croconut commented 3 months ago

Summary

closes #39

Adds functionality to check the output file type to enable JS codegen. When .js or .mjs, will output JS ESM code, when .cjs, will output CommonJS code.

Both JS format types will output fully typed code using JSDocs.

Additionally, can override the file type with --output-type, which accepts TS, CJS, or ESM and defaults to TS. Will not change the extension used. This was added so you can generate a .js as CommonJS and a way to output CommonJS to stdout.

Why bother

I use JSDocs + the typebox check compiler to get fast runtime checks for external inputs.

croconut commented 3 months ago

@xddq let me know if you want me to squash early, figured you could squash what you want on merge

croconut commented 3 months ago

@xddq im so used to not being able to run formatters x.x mb. ran it / checked wfs on the fork now