New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Static imports for $refs #579
Comments
To go around the issue I had to introduce a kind of
Each of the ones referenced in the above then references other schemas.
To get something like:
I do not like that export of |
@codan84 Are you also seeing duplicate interface declarations in the resulting output for |
As a workaround to generate unique classes, the best I could come up with is merged them into a single file. This has the benefit of not requiring a root schema, and provides unique (non-duplicate) class definitions: mkdir -p dist/generated && \
npx json2ts \
--no-declareExternallyReferenced \
--no-bannerComment \
--cwd=src \
-i 'src/*.schema.json' \
-o dist/tmp/ && \
cat dist/tmp/*.schema.d.ts > dist/generated/schema.d.ts |
This is definitely a bit of a hack but one work around I found was to do Then I split the schema generation into 2 steps. One for base types which should not import themselves and another for all my other types. Of course this doesn't really solve the full issue but at least gave me a path around this temporarily. |
Given structure like so:
schema/my-stuff.json :
schema/enums/awesome.json :
When I run the following cli command:
I will get roughly this:
packages/model/src/awesome.ts :
packages/model/src/my-stuff.ts :
Awesome
enum is now declared twice. And if I then reference thisAwesome
in any other schemas, it will be re-declared in every single file it is referenced.Am I missing some way to
import
these instead? Or alternatively having everything in 1 file...The text was updated successfully, but these errors were encountered: