КодНе начато
Задача на типы: позиции тостов
Сложность: лёгкий
С помощью шаблонных литеральных типов постройте ToastPosition (каждую пару horizontal-vertical, кроме 'center-center', плюс 'center') и CssLength (число, за которым идёт px, rem или %). Тест — Проверить типы.
Показать эталонное решение
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