3 ms·
> they are typechecked, so you couldn't have a type guard that claims to return a number but actually returns an array, at least not without bypassing the Types
by matt_kantor 4y ago
> they are typechecked, so you couldn't have a type guard that claims to return a number but actually returns an array, at least not without bypassing the Typescript checker some other way
Sadly this isn't true: https://tsplay.dev/WvGArw https://tsplay.dev/WvGArw
- MrJohz 4y agoGood point, I wasn't 100% sure on that and should have checked myself. I'd say there's still a lot of value in having type guards as explicit places that can be heavily checked, e.g. with unit tests, to form strong boundaries to the rest of the code you right.