https://www.typescriptlang.org/docs/handbook/2/objects.html#index-signatures [[インデックス型]]に数値を利用するとき、その数を文字列として扱っても両者は区別されない。 > It is possible to support both types of indexers, but the type returned from a numeric indexer must be a subtype of the type returned from the string indexer. This is because when indexing with a `number`, JavaScript will actually convert that to a `string` before indexing into an object. That means that indexing with `100` (a `number`) is the same thing as indexing with `"100"` (a `string`), so the two need to be consistent. つまり、以下のように動く。 ```ts const m = { 1: "hoge", "2": "huga" } console.log(m[1]) // hoge console.log(m["1"]) // hoge console.log(m[2]) // hoga console.log(m["2"]) // hoge ``` <button class="playground"><a href="https://www.typescriptlang.org/play?#code/MYewdgzgLgBAtjAvDA3gKBjAjALhgIgAsQBzAU3wBoMCAmfPIgVxIEN80BfNNUSEADZkAdANIAKOAG0sAXQCUaAPRKYxcr3ARBIsSUlT8WfAuWr1ZTfyGiJ02qZVrSrK9pt6D+eo-OkyQA">Playground</a></button>