Skip to content

Instantly share code, notes, and snippets.

@dagda1
Last active June 21, 2019 16:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dagda1/bad226eff297bf332517ed837b5f3faf to your computer and use it in GitHub Desktop.
Save dagda1/bad226eff297bf332517ed837b5f3faf to your computer and use it in GitHub Desktop.
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