7 Awesome TypeScript Types You Should Know

  Рет қаралды 76,628

Josh tried coding

Josh tried coding

9 ай бұрын

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

Пікірлер: 89
@sire_ns
@sire_ns 9 ай бұрын
I'll always appreciate these TS videos any day of the week
@kendanieleramiscal4923
@kendanieleramiscal4923 8 ай бұрын
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.
@DevoidFX
@DevoidFX 5 ай бұрын
The Prettify type should not exist. It should be a typescript configuration option.
@maxk5540
@maxk5540 5 ай бұрын
it is good until you are really need to have an object
@xinaesthetic
@xinaesthetic Ай бұрын
The semantics of what the higher level types are defined as is relevant information.
@timderks5960
@timderks5960 8 ай бұрын
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
@froxx93
@froxx93 9 ай бұрын
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.
@dominikrodler8010
@dominikrodler8010 Ай бұрын
One of the rare examples where a rather clickbaity sounding video really delivers 👍
@Nabulio85
@Nabulio85 8 ай бұрын
Great explanations, very well illustrated. Thanks
@chrise.3114
@chrise.3114 9 ай бұрын
Great stuff Josh! Please never stop posting new content!
@aselivra
@aselivra 8 ай бұрын
Fantastic video, simple, well explained and to the point. Great examples 👍
@ravinrod
@ravinrod 9 ай бұрын
Wow! These are good TypeScript tips. Thank you!
@GambitVil
@GambitVil 9 ай бұрын
Really nice, short but with so many good and important things video.
@shreyas0924
@shreyas0924 9 ай бұрын
We need more videos like these!! Great video buddy
@lakhveerchahal
@lakhveerchahal 6 ай бұрын
These are super cool tips. Thank you for sharing them
@Thassalocracy
@Thassalocracy 9 ай бұрын
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
@rahimco-su3sc
@rahimco-su3sc 9 ай бұрын
thanks a lot , we are constantly learning from your videos ! ,keep going
@njihiamark6926
@njihiamark6926 9 ай бұрын
great stuff Josh!
@luccaparadeda1985
@luccaparadeda1985 9 ай бұрын
Great video as always
@nidhish6966
@nidhish6966 9 ай бұрын
This helped me a lot, Thanks !
@solosdev6946
@solosdev6946 Ай бұрын
Thanks Josh helps alot for us :D
@elliottchong
@elliottchong 9 ай бұрын
Super helpful! Thank you :)
@carlosricardoziegler2650
@carlosricardoziegler2650 9 ай бұрын
Great content :) I ❤ typescript
@vorkosiganhs
@vorkosiganhs 7 ай бұрын
Amazing tips!! Thx a lot!
@LeLaboDeHarry
@LeLaboDeHarry 8 ай бұрын
So useful thank you!
@HG-wu6eb
@HG-wu6eb 8 ай бұрын
thank you let God bless you for your kind activity
@Leyksnal
@Leyksnal 9 ай бұрын
The best thing i have learnt today
@petarkolev6928
@petarkolev6928 9 ай бұрын
Wow! Thanks, Josh 🍻🍻
@abdulgaffarabdulmalik4333
@abdulgaffarabdulmalik4333 3 ай бұрын
Do you mean no matter how nested they are or no matter the number of Joins? Great video btw
@JacksonDiKey
@JacksonDiKey 8 ай бұрын
About Exlude is mind-blowing! Tnx
@vaibhav5783
@vaibhav5783 9 ай бұрын
This is more complex than learning rust or c or go. Anyway great video :)
@arifulhaque3236
@arifulhaque3236 9 ай бұрын
That's tips & tricks of Ts is time saving❤
@maxwebstudio
@maxwebstudio 8 ай бұрын
Nice one ! Thanks !
@Renzo-of3yn
@Renzo-of3yn 9 ай бұрын
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.
@TheIpicon
@TheIpicon 9 ай бұрын
great video!
@jagdishpadeliya6050
@jagdishpadeliya6050 9 ай бұрын
Very helpful 🔥
@cookieman.19
@cookieman.19 8 ай бұрын
This tutorial is valuable
@raymondmichael4987
@raymondmichael4987 9 ай бұрын
Thanks buddy 😊
@matthewbeardsley7004
@matthewbeardsley7004 9 ай бұрын
Yep, nice!! Thanks heaps!
@elormtsx
@elormtsx 9 ай бұрын
awesome pretty helpful!
@HtetMyat79
@HtetMyat79 9 ай бұрын
Very greate video thanks
@kilo.ironblossom
@kilo.ironblossom Ай бұрын
Prettify is now a vscode extension
@muradmesteliyev5651
@muradmesteliyev5651 9 ай бұрын
I wonder will you have a video about a project with bun?
@user-og9np8hp1h
@user-og9np8hp1h 9 ай бұрын
It is usefull to me thanks!
@lanskaba3668
@lanskaba3668 9 ай бұрын
Our brother always take us from darkness to light . Thank you Josh 🙏
9 ай бұрын
Master
@stasyanje4225
@stasyanje4225 7 күн бұрын
Being mainly a Swift developer I'm left shocked by TypeScript versatility
@ahmedkhairydev
@ahmedkhairydev 8 ай бұрын
Great types, you just forgetting `Pick` 👀
@latch909
@latch909 9 ай бұрын
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 9 ай бұрын
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 9 ай бұрын
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 8 ай бұрын
​@@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.
@tobiasnickel3750
@tobiasnickel3750 6 ай бұрын
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.
@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?
@LabhamJain
@LabhamJain 5 ай бұрын
You should have added Pick as well since you showed omit
@T25de
@T25de 9 ай бұрын
Fuck yea Nice one ☝️
@meka4996
@meka4996 9 ай бұрын
I think you can replace all "interface" with "type"
@shubhamrawat7895
@shubhamrawat7895 9 ай бұрын
type Person = keyof typeof obj type Return = ReturnType Partial Required type Omitted = Omit
@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
@Ultrajuiced
@Ultrajuiced 9 ай бұрын
5:46 Errr... and what will be the return type of updateTodo again? 😝 Looks like somebody forgot another spread operator: ...fieldsToUpdate
@aashiqahmed5273
@aashiqahmed5273 6 ай бұрын
prettify is good one
@alasassi5889
@alasassi5889 9 ай бұрын
Do u think ai will replace us one day
@manit77
@manit77 5 ай бұрын
this is good to know, but you don't need any of this besides making things more complex and harder to debug.
@sammy709
@sammy709 9 ай бұрын
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 9 ай бұрын
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 9 ай бұрын
@@IneyeGabriel I know the feature is useful, but the example makes it more confusing
@laturdaily5110
@laturdaily5110 9 ай бұрын
ReturnType Awaited Partial Required Omit Exclude
@AlanMeile
@AlanMeile 4 ай бұрын
& {} wtf
@JakeAndDaddy
@JakeAndDaddy 7 ай бұрын
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 :/
@DamirSecki
@DamirSecki 8 ай бұрын
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 :)
@greendsnow
@greendsnow 9 ай бұрын
sorry but this is not a high quality content...
@allone258
@allone258 9 ай бұрын
sorry but this is not a high quality comment
@juanps2721
@juanps2721 9 ай бұрын
That Prettify type makes the video high quality
@danieljanjanocha7178
@danieljanjanocha7178 9 ай бұрын
Like every developer finds a bug once in a while 😂
TypeScript Generics are EASY once you know this
22:21
ByteGrad
Рет қаралды 123 М.
Enums considered harmful
9:23
Matt Pocock
Рет қаралды 193 М.
Which one is the best? #katebrush #shorts
00:12
Kate Brush
Рет қаралды 20 МЛН
Backstage 🤫 tutorial #elsarca #tiktok
00:13
Elsa Arca
Рет қаралды 37 МЛН
Updates Like These Make Tailwind So Fun
8:00
Josh tried coding
Рет қаралды 71 М.
This TypeScript Trick Blew my Mind
6:17
Josh tried coding
Рет қаралды 36 М.
Learn TypeScript Generics In 13 Minutes
12:52
Web Dev Simplified
Рет қаралды 219 М.
Infer is easier than you think
13:38
Matt Pocock
Рет қаралды 85 М.
Why Does Scrum Make Programmers HATE Coding?
16:14
Thriving Technologist
Рет қаралды 491 М.
Fetching Data Doesn't Get Better Than This
6:58
Josh tried coding
Рет қаралды 75 М.
CSS Anchor Is The Best New CSS Feature Since Flexbox
15:39
Web Dev Simplified
Рет қаралды 356 М.
Type your functions in TypeScript and SAVE TIME
8:31
ThePrimeTime
Рет қаралды 47 М.
Bardak ile Projektör Nasıl Yapılır?
0:19
Safak Novruz
Рет қаралды 6 МЛН
МОЩНЕЕ ТВОЕГО ПК - iPad Pro M4 (feat. Brickspacer)
28:01
ЗЕ МАККЕРС
Рет қаралды 74 М.
iPhone 15 Unboxing Paper diy
0:57
Cute Fay
Рет қаралды 3,9 МЛН
How charged your battery?
0:14
V.A. show / Магика
Рет қаралды 5 МЛН
5 НЕЛЕГАЛЬНЫХ гаджетов, за которые вас посадят
0:59
Кибер Андерсон
Рет қаралды 1,6 МЛН