Skip to content

Instantly share code, notes, and snippets.

@meekg33k
Last active February 5, 2020 21:30
Show Gist options
  • Save meekg33k/bb16232ac0730b4469d38d9ce9c74df8 to your computer and use it in GitHub Desktop.
Save meekg33k/bb16232ac0730b4469d38d9ce9c74df8 to your computer and use it in GitHub Desktop.
Gists for Medium Post https://medium.com/p/177b4a654ef6
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