sinclairzx81 / typebox

Json Schema Type Builder with Static Type Resolution for TypeScript
Other
4.77k stars 152 forks source link

Revision 0.32.17 #799

Closed sinclairzx81 closed 5 months ago

sinclairzx81 commented 5 months ago

This PR adds a any type detection path for StaticDecode.

It is noted that even though the StaticDecode type is constrained to generic parameters of type TSchema; passing any for a parameter is still permissible as any does loosely satisfy this constraint. However in the context of StaticDecode, passing any does result in TS2589 instantiation issues due to any yielding union results when used as a left-side operand in conditional expressions (classic example below)

type T = any extends string ? 1 : 2 // T = 1 | 2

This PR attempts to catch any for StaticDecode specifically, principally because StaticDecode makes heavy use of conditional mapping, and where union results for any cause ambiguous resolution during type decoding.