What would be the best or most common way to declare an array type in TypeScript? There are several ways to do it but I'm not sure if it matters how you do it.
This is how I created the array type initially:
export type LayoutSpacingType = [number | SpacingInterface];
A colleague mentioned that it could also be done like this:
export type LayoutSpacingType = (number | SpacingInterface)[];
The difference is that one approach is wrapping the square brackets around both of the types, and the other one is just adding the square brackets at the end.
We are in doubt which one we should use. Are there any advantages or disadvantages for those approaches? Or will this basically compile to the same code and is the notation something that you could prefer on a personal level?
I did some research but couldn't find anything specific about the advantages / disadvantages. We want to make sure that we pick the best way to do it.