sinclairzx81 / typebox

Json Schema Type Builder with Static Type Resolution for TypeScript
Other
5.08k stars 161 forks source link

Revision 0.34.5 #1088

Closed sinclairzx81 closed 5 days ago

sinclairzx81 commented 5 days ago

This PR makes some updates to Computed Record types (Module).

Inline with 0.34.0, Computed types (Partial, Required, Omit, Pick, etc) are returned as TComputed when passed a TRef parameter which defers evaluation of the type until Module construction (where all reference targets are known). In TypeBox, Record types are also treated as Computed types because TypeBox will transform a Record with Finite keys into a TObject. This means that if the Record takes a TRef for a key, the target Key needs to be resolved prior to making the decision "Is the Key Finite?".

Prior to this PR, the TRecord type was also transforming to a TComputed if it observed a TRef for the Value parameter. However, as the Value parameter does not contribute information as to whether they Key is Finite or not, forcing a TComputed for the Value type is unnecessary.

This PR removes the TRecord<TRecordKey, TRef> -> TComputed path

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