- Популярные видео
- Авто
- Видео-блоги
- ДТП, аварии
- Для маленьких
- Еда, напитки
- Животные
- Закон и право
- Знаменитости
- Игры
- Искусство
- Комедии
- Красота, мода
- Кулинария, рецепты
- Люди
- Мото
- Музыка
- Мультфильмы
- Наука, технологии
- Новости
- Образование
- Политика
- Праздники
- Приколы
- Природа
- Происшествия
- Путешествия
- Развлечения
- Ржач
- Семья
- Сериалы
- Спорт
- Стиль жизни
- ТВ передачи
- Танцы
- Технологии
- Товары
- Ужасы
- Фильмы
- Шоу-бизнес
- Юмор
Union Types in TypeScript: One Value, Two Types #coding #codingtips
A value isn't always just one type. A union type lets a parameter be a number OR a string, and a typeof check tells TypeScript which one it is in each branch. That's narrowing.
In under a minute:
→ Why label("free") fails when the parameter is a number
→ How number | string allows both
→ Why toFixed breaks on a union
→ How typeof narrows the type inside an if
→ What's left after the if: just number
Next up: literal types.
Follow @BiteSizedCoding for a new bite-sized TypeScript tip every day.
#typescript #javascript #webdev
Видео Union Types in TypeScript: One Value, Two Types #coding #codingtips канала BiteSized Coding
In under a minute:
→ Why label("free") fails when the parameter is a number
→ How number | string allows both
→ Why toFixed breaks on a union
→ How typeof narrows the type inside an if
→ What's left after the if: just number
Next up: literal types.
Follow @BiteSizedCoding for a new bite-sized TypeScript tip every day.
#typescript #javascript #webdev
Видео Union Types in TypeScript: One Value, Two Types #coding #codingtips канала BiteSized Coding
Комментарии отсутствуют
Информация о видео
8 октября 2026 г. 23:51:41
00:00:49
Другие видео канала




