0

I am defining a array in a slice state with Redux Toolkit below:

export const initialState = {
  dice: [] as DieDTO[],
  loading: false,
  error: null,
}

I actually want to restrict this DieDTO[] array to be of ten die exactly, no more, no less:

  dice: [] as DieDTO[
Die, Die, Die, Die, Die, Die, Die, Die, Die, Die
],

It will force me to feed the array at initialize, but I'll fix that later.

The problem with the last answer is, that it's pretty difficult to read.

How can I achieve that more elegantly?

A Mehmeto
  • 1,594
  • 3
  • 22
  • 37
  • 2
    Does this answer your question? [Typescript: Can I define an n-length tuple type?](https://stackoverflow.com/questions/52489261/typescript-can-i-define-an-n-length-tuple-type) – jsejcksn Jan 27 '23 at 22:03

0 Answers0