SweetIQ / schemats

Generate typescript interface definitions from SQL database schema

Home Page:https://www.npmjs.com/package/schemats

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Support nullable type

abenhamdine opened this issue · comments

Hi and thx a lot for this module.

I just started to use this module, and I wonder if it's possible to generate typescript nullable type ?
Indeed, for ones who use typescript with --strictNullChecks flag, it would be very useful to generate types nullable with union type.

For example, for a SQL nullable string, it would generate type : string | null, etc.

I think it would be better to have this optional.

An idea would be to modifiy getTableDefinition to include SELECT is_nullable
Then use this information to generate : string | null or : string accordingly.

Hope this information can help you :)

OK, i will give a try.
Thx for the guidance.

Probably a good idea to try to merge https://github.com/gust/schemats/tree/enumtype first or implementing nullable type at the same time.