Тёмный

7 Awesome TypeScript Types You Should Know 

Josh tried coding
Подписаться 136 тыс.
Просмотров 76 тыс.
50% 1

These have saved me so much time in building out my apps, so I thought I'd share them with you. Hopefully they'll save you just as much time and nerves instead of figuring out all this yourself lol.
Matt Pocock explaining the Prettify Type: • Prettify for Classes
-- my links
Next.js SaaS: www.splitter.gg/
Discord: / discord
GitHub: github.com/joschan21

Наука

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

 

14 сен 2023

Поделиться:

Ссылка:

Скачать:

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

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 88   
@kendanieleramiscal4923
@kendanieleramiscal4923 7 месяцев назад
Another Typescript type, which is not included in the video, is the Pick type, which is the opposite of Omit. Instead of Omitting the property, you include the properties to be picked.
@timderks5960
@timderks5960 7 месяцев назад
Man, there's a LOT of information in here I never even heard of, but is pretty much exactly what I need, super cool. This would be a great video to add chapters to btw: 0:00 Intro 0:18 typeof / keyof 1:21 ReturnType / Awaited 2:59 Prettify (and nesting) 4:07 Partial / Required 5:58 Omit / Exclude
@sire_ns
@sire_ns 8 месяцев назад
I'll always appreciate these TS videos any day of the week
@DevoidFX
@DevoidFX 5 месяцев назад
The Prettify type should not exist. It should be a typescript configuration option.
@maxk5540
@maxk5540 4 месяца назад
it is good until you are really need to have an object
@xinaesthetic
@xinaesthetic 28 дней назад
The semantics of what the higher level types are defined as is relevant information.
@dominikrodler8010
@dominikrodler8010 Месяц назад
One of the rare examples where a rather clickbaity sounding video really delivers 👍
@froxx93
@froxx93 8 месяцев назад
The exclude util is not necessarily used for more complex types. It's for excluding types from union types in general instead of omitting props from an object type. So you could also use it to exclude e. g. string literals
@kesoBJJ
@kesoBJJ 8 месяцев назад
updateTodo example has a bug... you need to prefix fieldsToUpdate with ... if you want to override the todo, otherwise you will create an object with additional fieldsToUpdate property, which contains the values that should be used for updating.
@Thassalocracy
@Thassalocracy 8 месяцев назад
I'll never understand why interfaces hide their fields like it's something shameful lol. That Prettify type will save millions of developers including me.
@julian_handpan
@julian_handpan 8 месяцев назад
Bc it’s and interface 😂 not and object…
@mandokir
@mandokir 8 месяцев назад
Javascripters trying to understand object orientation.
@Netrole
@Netrole 8 месяцев назад
It used to be that way. But people complained that it is confusing and convoluted to see the result of the union when a union of preexisting types is made, instead they wanted to see which types the union is made of.
@vitvitvitvitvitvitvitvit
@vitvitvitvitvitvitvitvit 8 месяцев назад
​@@Netrole what hellll. i think would be pretty usefull show the type and your fields. Like: title: string; description: string; role: Role < { name: string, i id: number } >
@tylim88
@tylim88 8 месяцев назад
it is useful in creating branded type
@Nabulio85
@Nabulio85 7 месяцев назад
Great explanations, very well illustrated. Thanks
@chrise.3114
@chrise.3114 8 месяцев назад
Great stuff Josh! Please never stop posting new content!
@GambitVil
@GambitVil 8 месяцев назад
Really nice, short but with so many good and important things video.
@aselivra
@aselivra 8 месяцев назад
Fantastic video, simple, well explained and to the point. Great examples 👍
@ravinrod
@ravinrod 8 месяцев назад
Wow! These are good TypeScript tips. Thank you!
@lakhveerchahal
@lakhveerchahal 5 месяцев назад
These are super cool tips. Thank you for sharing them
@shreyas0924
@shreyas0924 8 месяцев назад
We need more videos like these!! Great video buddy
@rahimco-su3sc
@rahimco-su3sc 8 месяцев назад
thanks a lot , we are constantly learning from your videos ! ,keep going
@nidhish6966
@nidhish6966 8 месяцев назад
This helped me a lot, Thanks !
@vorkosiganhs
@vorkosiganhs 7 месяцев назад
Amazing tips!! Thx a lot!
@solosdev6946
@solosdev6946 Месяц назад
Thanks Josh helps alot for us :D
@elliottchong
@elliottchong 8 месяцев назад
Super helpful! Thank you :)
@njihiamark6926
@njihiamark6926 8 месяцев назад
great stuff Josh!
@carlosricardoziegler2650
@carlosricardoziegler2650 8 месяцев назад
Great content :) I ❤ typescript
@abdulgaffarabdulmalik4333
@abdulgaffarabdulmalik4333 3 месяца назад
Do you mean no matter how nested they are or no matter the number of Joins? Great video btw
@LeLaboDeHarry
@LeLaboDeHarry 8 месяцев назад
So useful thank you!
@JacksonDiKey
@JacksonDiKey 8 месяцев назад
About Exlude is mind-blowing! Tnx
@maxwebstudio
@maxwebstudio 8 месяцев назад
Nice one ! Thanks !
@luccaparadeda1985
@luccaparadeda1985 8 месяцев назад
Great video as always
@vaibhav5783
@vaibhav5783 8 месяцев назад
This is more complex than learning rust or c or go. Anyway great video :)
@arifulhaque3236
@arifulhaque3236 8 месяцев назад
That's tips & tricks of Ts is time saving❤
@HG-wu6eb
@HG-wu6eb 8 месяцев назад
thank you let God bless you for your kind activity
@raymondmichael4987
@raymondmichael4987 8 месяцев назад
Thanks buddy 😊
@TheIpicon
@TheIpicon 8 месяцев назад
great video!
@Renzo-of3yn
@Renzo-of3yn 8 месяцев назад
Josh, would be great if you make a video about the skills a junior developer should have to get their first job. THANKS 4 all your content.
@HtetMyat79
@HtetMyat79 8 месяцев назад
Very greate video thanks
@Leyksnal
@Leyksnal 8 месяцев назад
The best thing i have learnt today
@jagdishpadeliya6050
@jagdishpadeliya6050 8 месяцев назад
Very helpful 🔥
@cookieman.19
@cookieman.19 8 месяцев назад
This tutorial is valuable
@matthewbeardsley7004
@matthewbeardsley7004 8 месяцев назад
Yep, nice!! Thanks heaps!
@akarikev
@akarikev 8 месяцев назад
awesome pretty helpful!
@petarkolev6928
@petarkolev6928 8 месяцев назад
Wow! Thanks, Josh 🍻🍻
@muradmesteliyev5651
@muradmesteliyev5651 8 месяцев назад
I wonder will you have a video about a project with bun?
@user-og9np8hp1h
@user-og9np8hp1h 8 месяцев назад
It is usefull to me thanks!
@johnconnor9787
@johnconnor9787 3 месяца назад
3:45 Matt Pockock is a TS Ninja. He has a great channel. So as I understand he contributed to TS and created this type?
@kilo.ironblossom
@kilo.ironblossom 22 дня назад
Prettify is now a vscode extension
@ahmedkhairydev
@ahmedkhairydev 7 месяцев назад
Great types, you just forgetting `Pick` 👀
@latch909
@latch909 8 месяцев назад
I’m a bit confused when writing a function in TS aren’t we meant to declare the return type in the function declaration? When would you need to infer the return type??
@DavidWMiller
@DavidWMiller 8 месяцев назад
This question is kind of backwards. Why would you want to define it? If you can infer it, the types are done. Your code defined them. Manually defining is redundant extra work. There are cases where you might not want to infer them, but those are the ones you'd need reasons for, which is the opposite of your question.
@danieljanjanocha7178
@danieljanjanocha7178 8 месяцев назад
Let’s assume there is a function that returns an array of some kind of ingredients. In useState you want to declare that you want to keep array of some ingredients, but you start with an empty array. How to type the useState without knowing the return type of that function if you don’t wave the type specified elsewhere? It looks like an edge case but I can see a need for it sometimes
@gnack420
@gnack420 8 месяцев назад
​@@DavidWMiller no lol, declaring the return type is beneficial because a reader can see what the function returns without having to interpret the function.
@diegofernandocobacruz6508
@diegofernandocobacruz6508 7 месяцев назад
​@@gnack420Typescript shows you the inferred type when hovering the function name. No need for reading the code
@XxOsirisxX
@XxOsirisxX 4 месяца назад
@@diegofernandocobacruz6508 The IDE does that, not TypeScript. Open it on a notepad and hover it over.
@lanskaba3668
@lanskaba3668 8 месяцев назад
Our brother always take us from darkness to light . Thank you Josh 🙏
@shubhamrawat7895
@shubhamrawat7895 8 месяцев назад
type Person = keyof typeof obj type Return = ReturnType Partial Required type Omitted = Omit
@tobiasnickel3750
@tobiasnickel3750 5 месяцев назад
I wonder IS prettify could make typescript faster. Maybe not self implemented but As A buildin type. Because of then could avoid looking up complex structures.
@Ultrajuiced
@Ultrajuiced 8 месяцев назад
5:46 Errr... and what will be the return type of updateTodo again? 😝 Looks like somebody forgot another spread operator: ...fieldsToUpdate
8 месяцев назад
Master
@LabhamJain
@LabhamJain 4 месяца назад
You should have added Pick as well since you showed omit
@meka4996
@meka4996 8 месяцев назад
I think you can replace all "interface" with "type"
@realQuaz77
@realQuaz77 8 месяцев назад
This is not good. We are adding production code to augment IDE assists. I get why it exists, but this is something that should be supported by TS and the tool chain by default.
@simotasca
@simotasca 6 месяцев назад
thats true one thing that can be done is "tsc --noEmit --incremental --watch" and that at least shows the errors in the console
@T25de
@T25de 8 месяцев назад
Fuck yea Nice one ☝️
@alasassi5889
@alasassi5889 8 месяцев назад
Do u think ai will replace us one day
@aashiqahmed5273
@aashiqahmed5273 5 месяцев назад
prettify is good one
@sammy709
@sammy709 8 месяцев назад
The first example doesnt make a lot of sense. Why would you want Person to be either the string literal "name" or "age"
@IneyeGabriel
@IneyeGabriel 8 месяцев назад
It's just an example probably not the best one. But is super handy when you want to keep track of all keys within an Object or Enum
@sammy709
@sammy709 8 месяцев назад
@@IneyeGabriel I know the feature is useful, but the example makes it more confusing
@manit77
@manit77 4 месяца назад
this is good to know, but you don't need any of this besides making things more complex and harder to debug.
@laturdaily5110
@laturdaily5110 8 месяцев назад
ReturnType Awaited Partial Required Omit Exclude
@AlanMeile
@AlanMeile 4 месяца назад
& {} wtf
@JakeAndDaddy
@JakeAndDaddy 6 месяцев назад
Good content, but you need to slow down with the delivery. I'm an expert at other languages but only just kept up with it.
@NatoBoram
@NatoBoram 8 месяцев назад
Aaaaand the prettify type was fake :/
@greendsnow
@greendsnow 8 месяцев назад
sorry but this is not a high quality content...
@allone258
@allone258 8 месяцев назад
sorry but this is not a high quality comment
@juanps2721
@juanps2721 8 месяцев назад
That Prettify type makes the video high quality
@danieljanjanocha7178
@danieljanjanocha7178 8 месяцев назад
Like every developer finds a bug once in a while 😂
@DamirSecki
@DamirSecki 7 месяцев назад
can you please, pretty please, extremely please... not pronounce OUR as or and more like hour? (just phonetically like a-uaer, and not o-ur ... I don't know whay is this so annoying to me... but drives me nuts :)
Далее
TypeScript Generics are EASY once you know this
22:21
Просмотров 121 тыс.
This TypeScript Trick Blew my Mind
6:17
Просмотров 36 тыс.
The Worlds Most Powerfull Batteries !
00:48
Просмотров 11 млн
Part 37 - Introduction to Backtracking
4:32
Infer is easier than you think
13:38
Просмотров 84 тыс.
What is Span in C# and why you should be using it
15:15
How Did I Not Know This TypeScript Trick Earlier??!
9:11
Learn TypeScript Generics In 13 Minutes
12:52
Просмотров 209 тыс.
We Need to Talk About Redis.
14:55
Просмотров 87 тыс.
Why use Type and not Interface in TypeScript
14:12
Просмотров 189 тыс.
Generics: The most intimidating TypeScript feature
18:19
You SHOULD deploy to the edge.
12:06
Просмотров 52 тыс.
SAMSUNG S23 ULTRA🔥
0:47
Просмотров 144 тыс.
Power up all cell phones.
0:17
Просмотров 49 млн