At the risk of demonstrating my lack of knowledge surrounding TypeScript types - I have the following question.
When you make a type declaration for an array like this...
position: Array<number>;
...it will let you make an array with arbitrary length. However, if you want an array containing numbers with a specific length i.e. 3 for x,y,z components can you make a type with for a fixed length array, something like this?
position: Array<3>
Any help or clarification appreciated!
The JavaScript array has a constructor that accepts the length of the array:
However, this is just the initial size, there's no restriction on changing that:
TypeScript has tuple types which let you define an array with a specific length and types: