ThomasAribart / json-schema-to-ts

Infer TS types from JSON schemas đź“ť
MIT License
1.47k stars 31 forks source link

Any limits on the size of the schema? #14

Closed arose closed 3 years ago

arose commented 3 years ago

Really nice project, thank you!

Anyone tried it with large schemas and seen 1) performance degradation or 2) tsc using more relaxed typings because of the size?

ThomasAribart commented 3 years ago

Hello Alexander !

Thanks for the feedback 🤗

I use json-schema-to-ts on a large backend project (~200 routes, one schema each, small to medium-size), and did not notice any performance degradation. Our type test runs in ~20s.

I haven’t received any other feedback on performance degradation for the moment, so I think it’s ok.

I also never saw tsc relaxing the types.

The only issue I found on (very) large schemas is that you can sometimes encounter the following error: « Type instantiation is excessively deep and possibly infinite ».

That error is raised in the IDE but the types are still correctly inferred and it doesn’t happen on compilation 🤷‍♂️ It is a bit annoying and I’d be happy to have examples if you encounter some.

It can be avoided by splitting the schema into smaller schemas and recombining the types by hand.

Cheers

Thomas Aribart Developer +33 6 75 44 45 48 48 bd des Batignolles 75017 Paris

Le 2 mars 2021 Ă  04:34 +0100, Alexander Rose notifications@github.com, a Ă©crit :

Really nice project, thank you! Anyone tried it with large schemas and seen 1) performance degradation or 2) tsc using more relaxed typings because of the size? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

arose commented 3 years ago

Thanks, @ThomasAribart, for the answer and for the suggestion of splitting and recombining schemas