Created
April 12, 2018 07:54
-
-
Save tanepiper/d29bcbbbe96bbd45de8f89a82549c68a to your computer and use it in GitHub Desktop.
Type inference in typescript
This file contains hidden or 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
const foo = function <T>(a: T, b: T[]): any { | |
return { a, b } | |
} | |
foo(6, 'di') | |
foo(6, [9]) | |
foo<string>(6, 'di') | |
foo<string>('foo', 'di') | |
foo<string>('foo', ['di']) | |
foo<object>({}, [{}]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment