TCMiranda / joi-extract-type

Provides native type extraction from Joi schemas for Typescript
MIT License
152 stars 27 forks source link

Fix `extractType` type in TypeScript 3.9.6 #35

Closed bvallee-thefork closed 4 years ago

bvallee-thefork commented 4 years ago

extractType is currently displays the following error with TypeScript 3.9.x:

error TS2456: Type alias 'extractType' circularly references itself.

From the TypeScript team ^1:

Certain things can be deferred if there's a different declaration to "pause" the circularity at. I don't want to commit any specific circular behavior to bug/not bug; it depends on a lot of different factors and is sensitive to exactly where TS tries to resolve certain conditionals.

So basically, this PR keeps the same behavior as before, but uses a workaround to prevent the TypeScript 3.9.6 compiler from getting into a circularly references error state.

Fixes https://github.com/TCMiranda/joi-extract-type/issues/33

omairvaiyani commented 4 years ago

Works for us!

TCMiranda commented 4 years ago

Guys @omairvaiyani and @bvallee-thefork I pushed it to master, but I got some errors on one of my projects. I'll try to understand what happened there before I publish this, ok?

Also, autocomplete and inspections on vscode seem worst, did you try to make it better? Before: Screenshot from 2020-07-09 12-05-46

After: Screenshot from 2020-07-09 12-03-04