Type Assertions & Type Casting | Typescript Tutorial for Beginners

preview_player
Показать описание

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:

👇 Follow Me On Social Media:

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:

📚 Suggested Pre-requisites for this Typescript course:

📚 Tutorial References:

⚙ Web Dev Tools:

Was this Typescript Assertions and Type Casting tutorial helpful? If so, please share. Let me know your thoughts in the comments.

#typescript #assertions #casting
Рекомендации по теме
Комментарии
Автор

"strive for progress over perfection" this has gotten into my head. So simple but has a great effect.

I'm only a few vids in but I'm already thankful. You're awesome.

re.liable
Автор

I rarely have to rewind because the explanations are clear and concise from the start. Thanks man, the way you teach really sticks!

evant
Автор

Dave! I am waiting for a react typescript course/tutorial, maybe with avanced topics or a next js specialization too. You are the best!

oscardd
Автор

Is this really free???? Unbelievable!!!! You are godsend, thank you Dave

nguyenanh-vtjv
Автор

one of the best web developer teacher i have ever seen💙

mohammadrezaakhshabi
Автор

The best content on Typescript on youtube

kirillzlobin
Автор

@Dave, my solution for above challenge
const date: number = new Date().getFullYear();
const numberasString = (date as unknown) as string;
const span = as HTMLSpanElement;
const text =
span.appendChild(text);

sandyGamer
Автор

You’re truly a life saver! The best web dev content creator !!!

davidho
Автор

Amazing content ! I dont know if you're planning to do a paid version going deeper in typescript with react / node one day, but ill be you first buyer ! Is The Complete Web Developer of the same quality as your videos?

jdk
Автор

Waiting for Nextjs 13 course. Amazing content as always professor. Thank you for your efforts

teetanrobotics
Автор

alt + z => wraps code to the next line
shift + alt + downArrow => copy selected code

kirillzlobin
Автор

What a champ! Are you planning some Docker tutorials? Since, for me, it is really a tough concept to get a grasp on. Thank you for content of course!

polopol
Автор

Gracias MAESTRO sigo Saludos desde Venezuela. Att. Jose Grillo

Grishopping
Автор

Great tutorial, as always! Currently I need to watch them with subtitles (my ears don't work properly 🤨), I am glad that YouTube creates them automatically and I can watch your videos. 🙂

ScriptRaccoon
Автор

Remember to keep striving for progress over perfection, a little progress every day will go a very long way.

madhavjha
Автор

amazing tutorial, btw i guess you don't have to explicitly say the const thisYear is string since the toString() is already called

flowerofash
Автор

I might be wrong here but i think u can use angle brackets with react typescript for example i used it to define type of useState

codie
Автор

thank you for teaching! Big thank from Russia

biLLie_wiLLie
Автор

Dave, I have a piece of advice
can you please provide a couple of challenges to test our understanding of what you do?
I think it will be a useful
great job and keep going

mhdfirassbarakat
Автор

Great series. One question about type assertion (4.:48). I'm confused about how let c = a as Three. Why won't Typescript complain if I purposely initiate let a: One = "goodbye", since type Three has a literal type of "hello" which is different from variable a's value of "goodbye"? Thanks in advance.

joojoogamer