オブジェクトのkeyから値を取得

Object.keyでkeyを取得する。

Object.keys(オブジェクト)によってkeysを取得する。
keyskeyを集めたstring[]である。

private mono = {
	O_MONO : [
		[0, 0, 0, 0],
		[0, 2, 2, 0],
		[0, 2, 2, 0],
		[0, 0, 0, 0]
	],
	T_MONO : [
		[0, 0, 0, 0],
		[0, 3, 0, 0],
		[3, 3, 3, 0],
		[0, 0, 0, 0]
	],
};
 
const keys = Object.keys(this.mono); 
let cnt = 1;
 
for(const key of keys){
	let value : Field = this.mono[key as keyof typeof this.mono];
	result.set(cnt, value);
	cnt++;
}

この文のkey as keyof typeof this.monokeythis.monokeyだと明示している。
(これを付け加えないとエラーになる。)

let value : Field = this.mono[key as keyof typeof this.mono];