schema2typebox icon indicating copy to clipboard operation
schema2typebox copied to clipboard

feature request: change import style based on package.json "type"

Open croconut opened this issue 1 year ago • 0 comments

Library version:

1.7.1

JSON schema version: draft-04

I am willing to contribute to fix the issue 💚

The current behavior

It currently doesn't generate JS at all.

The expected behavior

If it generates JS (e.g. the feature request for JS creation is completed), it would be nice to resolve exported code as either common js or esm based on a combination of the (same directory or flag-argument) package.json's type & the output file's extension. At the moment, I'm have to locally wrap the code generator with some extras:

  • run on directories for input / output - really simple, not sure it requires a feature request, but would be nice QoL
  • convert the generated TS code to generate JSDocs / commonjs (its still miles ahead for integration testing) - im personally not a fan of wrapping codegen, really hard to know when i'll break it if i dont directly extend the library

Basically, I can't get my org to use TS so my workflow is sharing schemas with API consumers and use @typebox's compiler to do the live type checking.

croconut avatar Mar 06 '24 02:03 croconut