Typescript Index Signatures, keyof Assertions & the Record Utility Type

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

Typescript Index Signatures, keyof Assertions & the Record utility type are all useful when creating object types and accessing their properties dynamically. We look at examples using all 3 in this TS tutorial.

🚀 Become a full-stack web dev with Zero To Mastery Courses:

👇 Follow Me On Social Media:

Typescript Index Signatures, keyof Assertions & the Record Utility Type

(00:00) Intro
(00:05) Welcome
(00:30) Starter code and set up
(02:00) What are index signatures?
(02:33) Why you need an index signature
(06:09) Index signature syntax
(08:14) readonly modifier
(08:52) Non-existing properties
(09:52) Required properties combined with an index signature
(11:10) Optional properties
(13:40) keyof Assertions
(16:53) Record utility type vs index signatures

📚 Suggested Pre-requisites for this Typescript course:

📚 Tutorial References:

⚙ Web Dev Tools:

Was this Typescript Index Signatures, keyof Assertions & Record utility type tutorial helpful? If so, please share. Let me know your thoughts in the comments.

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

I know that you always say to strive for progress, but this one is perfection!

DiegoBM
Автор

This may be a year old but it's definitely given me a lot insight on how typescript works. Tysvm

Vietnamkid
Автор

I just want to say that these series came right on time. I've been tasked to refactor most of our projects to TypeScript and continueing that trend in the future, and while I did know a little bit about it I certainly didn't know it to this extent. So again, thanks for doing these!

xRichhhx
Автор

22:11 of course you can also intersect the Record type with another type which has an index signature, such as:
type Incomes = Record<Streams, number> & { [key: string]: number };

there is the added benefit that the compiler won't complain about dynamic indexing.

ua
Автор

Bless you sir, for keep posting videos of this series
Do make performance series from this
from basic to advance
Love from 🇮🇳

karansinghnegi
Автор

Amazing content, thank you very much Dave!

mirjana
Автор

Excellent Dave. Cleared so many doubts about Index Signatures and solutions off-course.

gmjitendra
Автор

Great video, also In time !!!
Yesterday I got error about indexes while refactoring code to ts from your another tutorial 'Node.js Full Course for Beginners' 7 hours.
Thank you <3

imigi
Автор

Hi Dave, I just want to say a very big thanks to you for putting out these series. I have watched all of the series and it was the best Typescript tutorial I've ever taken. I have started refactoring an admin panel project that was built purely with React into React with Typescript and I've never felt more confident in my Typescript skill. This is all thanks to the knowledge I got imparted through these amazing series. You're awesome Dave. Thank you.

hamedayinde
Автор

Best lessons on youtube i have seen. You are very good teacher! Thank you for all your videos, man.

denisborneman
Автор

Sir you really provide the best tutorials on every topic. thank you for all the efforts❤️

siddiqahmed
Автор

woo! this chapter is by far covers the most usefull typescript concepts. i remember how i learn typescript from a 3hour long video, indeed i was very confident util i incounter edge cases where typescript could not cover. and i though, maybe there are more to typescript than just 3 hour course. that's how i found this series from Dave which complements my incomplete typescript skills. it would have been better if i found this series in the first place.

adimardev
Автор

TS Fridays!! 🔥
This series feels like your personal EVH tribute 😂✌️

doors
Автор

This is literally the best course on typescript ever

johnconnor
Автор

Thank you very much for this tutorial! It has been very easy to follow! I have one question, tho, related to index signatures:
why if I declare
`[ index: string ]: string`
i can still go and create a new property doing something like
`const newInstance: IndexedType = {
bla: "string1"
}
newInstance[2] = "some string"`
and TS would create it without any issue even thought 2 is a number type and not a string type?

belenpeluffo
Автор

I think, keyof and typeof are not Assertions but Operators.

Assertions are used to inform the TypeScript compiler about the type of a value when it cannot be inferred, while type operators are language constructs used to manipulate and create new types based on existing types. Assertions are used at the value level to override the inferred type, while type operators operate at the type level to perform operations and create new types.

Anyways, thanks for free tutorials 😁

syedsadiq
Автор

Next.js or MongoDB can be the next course, please? Thanks Dave for creating such great free tutorials ever.

hoangthiendo
Автор

Hi Dave sir, i just notice in your vscode, there are square like line that wraps the block of your code on where you're cursor is. i thought i'ts super cool! and helpful for productivity. we would to know what extensions you are using. at the same time, i've been following lots of very high quality toturials from you and i felt so grateful and thankful for your efforts.

adimardev
Автор

Gracias... Reportandome YO por aqui... att. Jose. Grillo

Grishopping
Автор

Awesome video, as far as Record goes, is still don't find much of use for that Utility Type.

igorr