Shorthand property names
オブジェクトのキーと変数名が同じ時にかぎり、オブジェクトに値を代入するときも同様にShorthand property namesを使うことができます。これも分割代入と調べると情報を得られることがあります。次の例がほぼすべてです。
tstypeWild = {name : string;no : number;genre : string;height : number;weight : number;};constname = "pikachu";constno = 25;constgenre = "mouse pokémon";constheight = 0.4;constweight = 6.0;constpikachu :Wild = {name ,no ,genre ,height ,weight ,};
tstypeWild = {name : string;no : number;genre : string;height : number;weight : number;};constname = "pikachu";constno = 25;constgenre = "mouse pokémon";constheight = 0.4;constweight = 6.0;constpikachu :Wild = {name ,no ,genre ,height ,weight ,};
要するにこちらの省略型です。
tsconstpikachu :Wild = {name :name ,no :no ,genre :genre ,height :height ,weight :weight ,};
tsconstpikachu :Wild = {name :name ,no :no ,genre :genre ,height :height ,weight :weight ,};
もちろん一行で書くこともできます。
tsconstpikachu :Wild = {name ,no ,genre ,height ,weight };
tsconstpikachu :Wild = {name ,no ,genre ,height ,weight };