typescript-is
typescript-is copied to clipboard
Fix intersections with primitives to add support for nominal types
as issue #110 stated mention, typescript-is does not support adding nominal types. while typescript does for example:
type USD={id:'usd'} & number
const usd: USD = 5 as USD // typescript allow this
const x=5;
console.log(is(<USD>(x)) // --> false
Suggested fix
we can notice that every time we intersect an object with primitive type the return type will the primitive type, So simply what I did is return the that primitive type when ever there is intersection between it and any object