Skip to content

Instantly share code, notes, and snippets.

@cellog
Created August 30, 2019 18:56
Show Gist options
  • Save cellog/f483996bad0dc4073c9174f9ea83f996 to your computer and use it in GitHub Desktop.
Save cellog/f483996bad0dc4073c9174f9ea83f996 to your computer and use it in GitHub Desktop.
Basic Typescript Type Inference
// basic type inference
function inferred() {
const a = 'hi'
return a
}
// inferred from interface definition
interface DefinesTypes {
inferred: (first: number, second: string) => number
}
const f: DefinesTypes = {
inferred(first, second) {
return first + second.length
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment