Skip to content

Instantly share code, notes, and snippets.

@dagda1 dagda1/foo.ts
Last active Jun 21, 2019

Embed
What would you like to do?
interface Foo {
value?: string;
}
const item1: Foo = { value: 'foo' }
// ERROR: Object is possibly 'undefined'.
console.log(`Message ${item1.value.substring(4)}`);
const item2 = { value: 'foo' }
// all good in the hood
console.log(`Message ${item2.value.substring(4)}`);
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.