Last active
February 5, 2020 21:30
-
-
Save meekg33k/bb16232ac0730b4469d38d9ce9c74df8 to your computer and use it in GitHub Desktop.
Gists for Medium Post https://medium.com/p/177b4a654ef6
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
type SomeObjectType = { | |
id: number; | |
text: string; | |
} | |
let someObject: SomeObjectType | undefined; | |
if (someObject && Object.keys(someObject).length > 0) { | |
//This evaluates as truthy because it's not undefined | |
someObject.id = 12; //TS compiler doesn't complain here because the object exists | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment