You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Undefined and Null types which can be used with conditional transformations and checks - null & Transform<...> is never, so these types need to exist.
PostCheck utility type which can be used alongside Transform to perform validation of the transformed values.
Changes
The playground now uses astro instead of next.js, and it's URL has been changed to googlefeud.github.io/ts-runtime-checks/playground. I'll be writing better and more interactive documentation over the next few weeks!
You'll no longer see stringified typescript types inside errors, they've been made a lot more readable.
Union type data now includes the possible variants in raw errors.
You can now use unions with check types: (implements #40)
functionvalidate1(param: Assert<Min<10>&Max<30>|string&(StartsWith<"a">|MinLen<3>)|number[]&MinLen<3>>){returntrue;}// Transpiles to:functionvalidate1(param){if((typeofparam!=="string"||!param.startsWith("a")&¶m.length<3)&&(typeofparam!=="number"||param<10||param>30))if(!Array.isArray(param)||param.length<3)thrownewError("Expected param to be number, to be greater than 10 & to be less than 30 | string, to start with \"a\" or to have a length greater than 3 | array<number>, to have a length greater than 3");else{for(leti_1=0;i_1<param.length;i_1++){if(typeofparam[i_1]!=="number")thrownewError("Expected param["+i_1+"] to be a number");}}returntrue;}
Breaking changes
Removed the Or utility type - use the | operator.
Changed the Eq utility type to be more flexible, its parameters have been reversed, and the type is now optional.