Type Assertions & Type Casting | Typescript Tutorial for Beginners
Dave Gray
@davegrayteachescodeAbout
Web Development tutorials with full courses on HTML, CSS, JavaScript, React, Node.js and more! My goal is to help you learn how to build the web. Teaching helps me learn, too. I work full-time as a Solutions Architect / Developer and part-time as a university web dev instructor. Thank you for subscribing, supporting my channel and sharing the videos you think may help others. Keep striving for progress over perfection. And a little progress every day goes a very long way. Milestones: July 20, 2020 - 1st video Jan 1, 2021 - 1k subs April 2021 - 4k watch hours Nov 2021 - 10k subs Jan 21, 2022 - Video at 100k views Feb 16, 2022 - 100k watch hours Feb 19, 2022 - 1m views Dec 13, 2022 - 100k subs Dec 2022 - Over 1m views in 1 month April 7, 2023 - 10m views May 26, 2023 - 1m watch hours Sept 22, 2023 - Video at 1m views Dec 25, 2023 - 250k subs
Video Description
Web Dev Roadmap for Beginners (Free!): https://bit.ly/DaveGrayWebDevRoadmap Learn Type Assertions & Type Casting in this Typescript tutorial for beginners. Learn more about type assertions and type casting and complete a Typescript student challenge in detailed TS tutorial. ๐ Become a full-stack web dev with Zero To Mastery Courses: - The Complete Web Developer: https://bit.ly/WebDevMaster - Master the Coding Interview: https://bit.ly/FAANGInterview - Junior to Senior Dev Roadmap: https://bit.ly/WebDevRoadmap-JrtoSr ๐ฉ Subscribe โ https://bit.ly/3nGHmNn ๐ฌ Course Updates โ https://courses.davegray.codes/ โ Questions - Please post them to my Discord โ https://discord.gg/neKghyefqh โ Buy Me A Coffee โ https://www.buymeacoffee.com/davegray ๐ Follow Me On Social Media: Github: https://github.com/gitdagray Twitter: https://twitter.com/yesdavidgray LinkedIn: https://www.linkedin.com/in/davidagray/ ๐ All Resources for this Typescript Course: https://github.com/gitdagray/typescript-course ๐ Playlist for this Typescript Course: http://bit.ly/3GcNJ78 Type Assertions & Type Casting | Typescript Tutorial for Beginners (00:00) Intro (00:05) Welcome (00:28) Type Assertions vs Type Casting (01:18) What are Type Assertions? (01:58) Starter Code (03:44) Converting Types with Assertions (04:53) Angle Bracket Syntax instead of "as" (05:55) Narrowing Return Values with Assertions (08:37) Caution: Assertions allow mistakes! (10:07) Double Casting and the unknown type (12:03) DOM Selection Types (16:19) Non-Null Assertions (17:43) Angle Brackets and the DOM (18:14) Student Challenge (21:27) Solution 1: Beginners (24:13) Solution 2: Type Assertion Corrections: (13:50) Syntax error: document.getElementById('img') is what is needed if the element has an id set to "img". This does not change the concept I'm discussing. Just tired eyes and a syntax error. ๐ Suggested Pre-requisites for this Typescript course: ๐JavaScript for Beginners full course: https://youtu.be/EfAl9bwzVZk ๐ Tutorial References: ๐ Typescript Official Website: https://www.typescriptlang.org/ ๐ Anders Hejlsberg, Creator of Typescript and C# Interview: https://dev.to/destrodevshow/typescript-and-c-both-created-by-the-same-person-named-anders-hejlsberg-42g4 ๐ Stackoverflow Survey Results: https://survey.stackoverflow.co/2022/#technology-most-popular-technologies ๐ MDN - Static Typing: https://developer.mozilla.org/en-US/docs/Glossary/Static_typing ๐ MDN - Dynamic Typing: https://developer.mozilla.org/en-US/docs/Glossary/Dynamic_typing ๐ MDN - Type Coercion: https://developer.mozilla.org/en-US/docs/Glossary/Type_coercion ๐ TS Type Assertions: https://www.typescriptlang.org/docs/handbook/2/everyday-types.html#type-assertions โ Web Dev Tools: ๐ Chrome Browser: https://www.google.com/chrome/ ๐ Visual Studio Code (VS Code): https://code.visualstudio.com/ ๐ Node.js & npm: https://nodejs.org/ ๐ Live Server VS Code Extension: https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer Was this Typescript Assertions and Type Casting tutorial helpful? If so, please share. Let me know your thoughts in the comments. #typescript #assertions #casting
Essential Gaming PC Parts
AI-recommended products based on this video

Beelink SER3 Mini Desktop PC with AMD Ryzen 3 3200U 2C/4T, 16GB DDR4 500GB PCIE3.0 X4 SSD, Dual Display Output, WiFi6/BT5.2 W-11 Pro Mini Gaming Computer

Beelink SER3 Mini PC, AMD Ryzen 3 3200U(14nm, 2C/4T) up to 3.5GHz, Mini Gaming Computer 16GB DDR4 RAM 500GB PCIE3.0 X4 SSD, Micro PC 4K@60Hz Dual Display, Mini Computer WiFi6/BT5.2/HTPC/W-11 Pro

Beelink SER3 Mini PC, AMD Ryzen 3 3200U(up to 3.5GHz) 2C/4T, Mini Computer 16GB DDR4 RAM 500GB SSD, Mini Desktop Computer 4K@60Hz Dual HDMI Display WiFi6/BT5.2/WOL/HTPC/W-11 Pro

EVGA GeForce GTX 1660 Ti XC Ultra Gaming, 6GB GDDR6, HDB Fan Graphics Card 06G-P4-1267-KR

CORSAIR Hydro X Series iCUE Link XH405i Custom Cooling Kit โ Hardline Water Cooling Loop โ XC7 Elite CPU Water Block โ XD5 Elite D5 Pump Res โ XR5 360mm Radiator โ 3X QX120 RGB Fans

Logitech G203 Wired Gaming Mouse, 8,000 DPI, Rainbow Optical Effect LIGHTSYNC RGB, 6 Programmable Buttons, On-Board Memory, Screen Mapping, PC/Mac Computer and Laptop Compatible - Black

CORSAIR iCUE Link XD5 RGB Elite LCD Pump-Reservoir Unit - D5 PWM Pump - 480x480 IPS LCD Screen - 22 Addressable RGB LEDs - 440ml Nylon Reservoir - White

CORSAIR iCUE Link XC7 RGB Elite CPU Water Block - Transparent Flow Chamber - 24 RGB LEDs - Fits Intelยฎ LGA 1700, AMDยฎ AM5 and Older - White

CORSAIR Hydro X Series iCUE Link XH405i Custom Cooling Kit โ Hardline Water Cooling Loop โ XC7 Elite CPU Water Block โ XD5 Elite D5 Pump Res โ XR5 360mm Radiator โ 3X QX120 RGB Fans




















