Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
TypeScript 関数の書き方メモ
// function 文の型注訳
function func0(str:string):string{
return str;
}
// ------------------------------------------------
// function 式の型注訳
var func1:(str:string) => string = function(str){
return str;
};
//var func1_2:(str:string) => string = function(str:string):string{
// return str;
//};
// 注訳してるから意味なくない?
//function func2(str:Vector2):string;
var func2:Function = function(str:string):string{
return str;
}
// ------------------------------------------------
// アロー関数
var func3:Function = (str:string):string => {
return str;
}
// ------------------------------------------------
// オーバーロード
function func4(str:string,num:number):string;
function func4(str:string):string{
return str;
}
// ------------------------------------------------
var obj:Object = {
func:function(str:string):string{
return str;
},
arrowFunc:(str:string):string => {
return str;
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.