We have this code at our work, which i wanted to know the difference between it and just manually typing out the same thing.
const tuple = <T extends string[]>(...args: T) => args;
const strings = tuple(
'blabla',
'default',
'standard'
);
export type Strings = typeof strings[number];
When i hover over “Strings”, it basically is type Strings = 'blabla' | 'default' | 'standard'
My question is, why not just simply type out the samething?
type Strings = 'blabla' | 'default' | 'standard';
Instead of all the tuple stuff? I can’t see a difference, but if someone could explain why we’re using this Tuple function that would be great