ThomasAribart / json-schema-to-ts

Infer TS types from JSON schemas ๐Ÿ“
MIT License
1.43k stars 30 forks source link

Possible regression in 2.9.0 #144

Closed mhio closed 1 year ago

mhio commented 1 year ago

When using json-schema-to-ts via @fastify/fastify-type-provider-json-schema-to-ts the 2.9.0 release is producing issues converting schemas to types.

I only raise this issue here as 2.9.0 doesn't appear to be a feature release, just a change in the release process, so I thought a change in behaviour would be of interest here.

https://github.com/fastify/fastify-type-provider-json-schema-to-ts/issues/49

Similar to #132 but I couldn't reproduce the issue in fastify-type-provider-json-schema-to-ts depending on 2.8.0, 2.8.1 or 2.8.2 so appears on the surface to be something different.

aardvarkk commented 1 year ago

I'm seeing the same issue as Fastify around "Type instatiation is excessively deep and possibly infinite". Reverting to v2.8 fixes the issue.

ThomasAribart commented 1 year ago

Thanks for the heads up! Very weird indeed as there has been no change in the source code between 2.8.2 and 2.9, only CI/CD stuff. Will be looking at that tomorrow, meanwhile feel free to stay on 2.8.2!

tizmagik commented 1 year ago

I was getting this same error and I had to downgrade to exactly 2.8.0 for it to work. TypeScript v5.0.4

Physicliar commented 1 year ago

I am using serverless framework aws-serverless-typescript template and getting the same error event 2.8.0 or 2.9.0 or even 2.7.0.

TypeScript v5.0.4

ThomasAribart commented 1 year ago

@Physicliar It was fixed in 2.8.2 I think

ThomasAribart commented 1 year ago

Just looked at it, the builds of 2.8.2 and 2.9.0 are exactly the same, except that in 2.8.2, all types are declared and not in 2.9.0.

yo ts โ€” castore (Workspace) 2023-05-27 11-29-43

I'm not sure why exactly, but it's probably what caused the regression (it's the only diff I see anyway). It seems it came from using the v4.9.5 of TS to build the types instead of the ^4.5.5. Will try to fix that ASAP.

ThomasAribart commented 1 year ago

@mhio @aardvarkk @tizmagik @Physicliar Can you try with 2.9.1 ? The declares are now back so the code should be exactly the same as 2.8.2.

Strangely, it also solved a deno build issue (here 2.9.0 vs 2.9.1):

v2 9 0 ๐ŸŒˆ ยท ThomasAribart:json-schema-to-ts@e211f20 2023-05-27 12-01-14 v2 9 1 ๐ŸŒˆ ยท ThomasAribart:json-schema-to-ts@01f639b 2023-05-27 12-00-23
aardvarkk commented 1 year ago

@ThomasAribart I can confirm that upgrading from 2.9.0 to 2.9.1 fixes the "Type instantiation is excessively deep and possibly infinite" issue for me.

ThomasAribart commented 1 year ago

Great ๐Ÿ‘ Closing this issue then!

mhio commented 1 year ago

Thanks Thomas!