Skip to content

Instantly share code, notes, and snippets.

@vvakame
Created February 13, 2013 07:03
Show Gist options
  • Save vvakame/4942802 to your computer and use it in GitHub Desktop.
Save vvakame/4942802 to your computer and use it in GitHub Desktop.
TypeScriptでの構造的部分型の説明をざっくりやった
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