sinclairzx81 / typebox

Json Schema Type Builder with Static Type Resolution for TypeScript
Other
4.56k stars 148 forks source link

Revision 0.32.31 #881

Closed sinclairzx81 closed 1 month ago

sinclairzx81 commented 1 month ago

This PR implements a fix on Value.Cast to dereference Union variants before scoring them. This is required as the current Union differentiation algorithm only works on instances of TObject and where fall through cases (for example TRef) would blindly score referenced objects with a binary 0 or 1 value.

It was observed that in fall through cases where no variants match the value, the first union variant was selected.

Fixes https://github.com/sinclairzx81/typebox/issues/880