is
Last updated
Last updated
is
is meant to be used in conjunction with assert and enable you to tell the compiler:
"Trust me this value
is of type T
" or "Trust me this value
is not of type T
"
Equally useful you can tell TypeScript that your shape is not a Square
, it will infer that, it is then a Circle
.
It is important to understand that here that when you run the instruction assert(typeGuard<Circle>(shape))
if the shape happens not to be a Circle you won't get an error at runtime.