Skip to content

Instantly share code, notes, and snippets.

@meekg33k

meekg33k/some-object.ts

Last active Feb 5, 2020
Embed
What would you like to do?
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
You can’t perform that action at this time.