-
Notifications
You must be signed in to change notification settings - Fork 213
Description
When a type is imported from another file - even a simple object type - the generated schema includes an extra $ref
and definition, unlike the same type defined inline.
Reproduction
Repo: https://github.com/alexchexes/ts-jsg-import-vs-inline-repro
Compare:
Expected
Same schema structure for both files - flattened shape directly under MyObject
.
Actual result
Schema for the import
version uses a $ref
to a separate definition, making the output structurally different.
Impact
While this is a minimal reproduction, in real-world projects the impact is significant.
For example, using almost any non-trivial utility type from type-fest
(or manually crafted helpers like DeepPartial
, Merge
, etc.) results in a bloated schema with long, chained $ref
s and generic type names like:
"OverrideProperties<interface-13180666-71-18834-...,structure-13180666-0-32472[false,{}]>"
Even when the structure is identical, the generator produces separate definitions for each imported utility in the chain - making the schema harder to read, debug, compare, and test.