Created
February 13, 2013 07:03
-
-
Save vvakame/4942802 to your computer and use it in GitHub Desktop.
TypeScriptでの構造的部分型の説明をざっくりやった
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 A { | |
hoge(str:string): string; | |
} | |
interface B { | |
hoge(str:string): string; | |
} | |
class AImpl { | |
hoge(str) { | |
return str + "&" + str; | |
} | |
} | |
var fn = function(b: B) { | |
alert(b.hoge("test")); | |
} | |
fn(new AImpl()); | |
var aImpl = { | |
hoge:(str:string):string => { return "triple:" + str + str + str; } | |
}; | |
fn(aImpl); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment