ThomasAribart / json-schema-to-ts

Infer TS types from JSON schemas 📝
MIT License
1.43k stars 30 forks source link

FromExtendedSchema fails to compile #132

Closed royhamulak closed 1 year ago

royhamulak commented 1 year ago

PR#130 introduced FromExtendedSchema

when installing version 2.8.0 and trying to build my project I was getting the following error:

node_modules/json-schema-to-ts/lib/types/index.d.ts:16:314 - error TS2590: Expression produces a union type that is too complex to represent.
16 export declare type FromExtendedSchema<E extends JSONSchema7Extension, S extends ExtendedJSONSchema<E>, Opt extends FromExtendedSchemaOptions<E> = FromSchemaDefaultOptions, W extends $ExtendedJSONSchema7<E> = Cast<S extends Record<string | number | symbol, unknown> ? Writable<S> : S, $ExtendedJSONSchema7<E>>> = FromSchema<Cast<UnextendJSONSchema7<E, W>, JSONSchema>, Opt>;

I was using typescript 5 as it wasn't supposed to mess with anything on my side but seems like it doesn't like this new type

ronyehu commented 1 year ago

this is very critical as any sub-dependency that uses this, upon update fails to build. please resolve this asap! Thanks!

stebl commented 1 year ago

I ran into this with json-schema-to-ts 2.6.2. It was the upgrade to TS 5.x that surfaced the compilation error. In my case I'm able to continue using TS 4.9.5 for the time being.

my-repo
|- my-package
|  |- json-schema-to-ts 2.6.2
|- TS 5.0.4

Compilation in my-repo fails.

ThomasAribart commented 1 year ago

Should be fixed in 2.8.2