Created
August 30, 2019 18:56
-
-
Save cellog/f483996bad0dc4073c9174f9ea83f996 to your computer and use it in GitHub Desktop.
Basic Typescript Type Inference
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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