Last active
May 11, 2016 17:49
-
-
Save jeffmo/ae22177b9c8df28a5b8a209ff805288b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var a: mixed = foo(); | |
var b: number; | |
b = a; // error! `a` might not be a number... Could be anything! | |
if (typeof a === 'number')) { | |
b = a; // This is safe -- no error | |
} else { | |
throw new Error('Unexpected type of `a`!'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment