Skip to content

Instantly share code, notes, and snippets.

@TheCubicleBuddha
Created April 19, 2019 20:10
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 TheCubicleBuddha/a72746c062b8386b33b9752d5d15d8c4 to your computer and use it in GitHub Desktop.
Save TheCubicleBuddha/a72746c062b8386b33b9752d5d15d8c4 to your computer and use it in GitHub Desktop.
In this example, we no longer get a runtime exception because we've communicated our needs.
function getUserById(id: number){
// hits a database and returns the value
}
const guid = "b5f770f2-197c-4bf5-a31f-cfec4f545d06";
const user = getUserById(guid);
// ^ Compiler error: Argument of type string is not assignable to parameter of type 'number'.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment