Typescript: Can I define an n-length tuple type?

后端 未结 3 786
轮回少年
轮回少年 2020-12-06 00:50

I am creating a shogi game board using Typescript. A shogi board has 9 ranks and files.

I\'d like to assert a 9x9 multidimensional array as a type to ensure both the

3条回答
  •  无人及你
    2020-12-06 01:34

    One quick simplification would be to create a Tuple9 type, that can be used to create the first level as well as the second level of the matrix:

    type Tuple9 = [T, T, T, T, T, T, T, T, T]
    type Board9x9

    = Tuple9>

提交回复
热议问题