Тёмный

TypeScript Type Guards Explained 

Подписаться
Просмотров 9 тыс.
% 277

TypeScript tutorial on how to use Guards such as typeof, instanceof, in and user-defined TypeScript Guards.
======⚡⚡⚡======
Consider supporting the channel by clicking the "Thanks" button ❤️
👉 Get a 20% discount on Brilliant.org (to learn Science, Technology, Engineering, and Math): brilliant.sjv.io/kjVO2z
======⚡⚡⚡======
🙌 Become my Patreon and get exclusive perks: patreon.com/softdevdiaries
💼 Follow me on LinkedIn and drop me a message if you'd like: linkedin.com/in/gusgadirov
💻 Also, let's connect on GitHub: github.com/gusgad
📚 Resources:
TypeScript predicates: www.typescriptlang.org/docs/handbook/advanced-types.html#using-type-predicates
And don't forget to subscribe for more videos like this 😊

Наука

Опубликовано:

 

23 окт 2022

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 6   
@sandorturbucz425
@sandorturbucz425 10 месяцев назад
This is one of the smarter aspects of using TS, good explanation. Some small side note, at 4:40 in real life we probably should use (unless it's on purpose) Object.hasOwn() instead of in, because the latter also finds the properties through the prototype chain.
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries 10 месяцев назад
Great point!
@fusion.chronicles
@fusion.chronicles 11 дней назад
The best explanation so far 👍
@jvsvogler
@jvsvogler Год назад
Really helpful, thanks a ton!
@SoftwareDeveloperDiaries
@SoftwareDeveloperDiaries Год назад
Glad it helped!
@rajsatraroxor9603
@rajsatraroxor9603 Месяц назад
In last example, while changing from fruit instanceof to isTasty in, last keyword "Banana" should be changed to parameter "fruit", to check isTasty exisits or not in fruit which is passed into that function
Далее
ЧУТЬ НЕ УТОНУЛ #shorts
00:27
Просмотров 3,4 млн
Собери ПК и Получи 10,000₽
1:00
Просмотров 2,7 млн