CódigoSin intentar
Reto de tipos: posiciones de toasts
Dificultad: fácil
Usa tipos template literal para construir ToastPosition (cada par horizontal-vertical excepto 'center-center', más 'center') y CssLength (un número seguido de px, rem o %). El test es Comprobar tipos.
Ver solución de referencia
export type Horizontal = 'left' | 'right' | 'center';export type Vertical = 'top' | 'bottom' | 'center';
// A template literal over unions expands to their cross product; Exclude drops the redundant one.export type ToastPosition = Exclude<`${Horizontal}-${Vertical}`, 'center-center'> | 'center';
// `${number}` matches any numeric string, so this checks the shape, not just "some string".export type CssLength = `${number}${'px' | 'rem' | '%'}`;
Ctrl Enter