Skip to content

Instantly share code, notes, and snippets.

@maritz
Created August 26, 2016 22:33
Show Gist options
  • Save maritz/e990a61173b5440b0e68b9b695ad718d to your computer and use it in GitHub Desktop.
Save maritz/e990a61173b5440b0e68b9b695ad718d to your computer and use it in GitHub Desktop.
strict null checks with function that always sets non-null (.js extension simply for highlighting... this is typescript)
let foo: null | string = null;
function setFoo(newFoo = 'bar') {
foo = 'baz' + newFoo;
}
setFoo();
console.log(foo.match('ba'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment