schema2typebox icon indicating copy to clipboard operation
schema2typebox copied to clipboard

feature: add JavaScript codegen

Open croconut opened this issue 1 year ago • 3 comments

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 avatar Mar 18 '24 21:03 croconut

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

croconut avatar Mar 18 '24 21:03 croconut

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

croconut avatar Mar 19 '24 17:03 croconut