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:
Same schema structure for both files - flattened shape directly under MyObject.
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 $refs and generic type names like:
"OverrideProperties<interface-13180666-71-18834-...,structure-13180666-0-32472[false,{}]>"
See example (src)
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.
When a type is imported from another file - even a simple object type - the generated schema includes an extra
$refand definition, unlike the same type defined inline.Reproduction
Repo: https://github.com/alexchexes/ts-jsg-import-vs-inline-repro
Compare:
main-inline.ts→schema-inline.jsonmain-import.ts→schema-import.jsonExpected
Same schema structure for both files - flattened shape directly under
MyObject.Actual result
Schema for the
importversion uses a$refto 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 likeDeepPartial,Merge, etc.) results in a bloated schema with long, chained$refs and generic type names like:See example (src)
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.