Created
March 26, 2014 20:51
-
-
Save keroserene/9793166 to your computer and use it in GitHub Desktop.
Typescript void generic problem
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
interface Foo<T> { | |
bar<T2>(callback:(t:T)=>T2) : T2; | |
} | |
var foo :Foo<string>; | |
// Works as expected. | |
foo.bar<number>((s:string) => { | |
return 12345; | |
}); | |
// Succeeds silently when it should actually fail... | |
foo.bar<void>((s:string) => { | |
return 5; // Not a void!!! | |
}); | |
// Fails as expected. | |
foo.bar<number>((s:string) => { | |
}); | |
// Fails as expected. | |
foo.bar((n:number) => {}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment