Example:
type DefaultTheme = {
name: 'default';
colors: [string, string, string];
};
type CustomTheme = {
name: 'custom';
colors: [string, string, string, string, string];
};
type DefaultColor = ???; // 'default-1' | 'default-2' | 'default-3';
type CustomColor = ???; // 'custom-1' | 'custom-2' | 'custom-3' | 'custom-4' | 'custom-5';
The question is whether it's possible to use the length of the colors array to create a mapped union type as in the given example.
The example is simplified for (hopefully) clarity, but in full there is a generic type Theme that takes name and length arguments and uses length to generate a tuple of fixed number of strings.