ThomasAribart / json-schema-to-ts

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

bsonType deserialisation not working anymore in version 2.7.2 #128

Closed gurumaxi closed 1 year ago

gurumaxi commented 1 year ago

I am specifying my mongodb database model via json schema including bsonType attributes (e.g. objectIdand date). To generate a typescript type from this schema, I am using FromSchema and I deserialize the bsonType fields to strings via the deserialize array. With version 2.7.2 this is not working anymore. For every bsonType field, the error Property 'xxx' is incompatible with index signature appears. How can I achieve the previous behaviour with version 2.7.2?

ThomasAribart commented 1 year ago

@gurumaxi Sorry I had to remove it as it caused a bug in tuples.

Working on it right now, I have found another lead that's interesting (providing extension in options). Will probably happen in 2.8 !

ThomasAribart commented 1 year ago

@gurumaxi Since 2.8.0, json-schema-to-ts exposes ExtendedJSONSchema and FromExtendedJSONSchema types just for that 🥳

See docs: https://github.com/ThomasAribart/json-schema-to-ts#extensions