7 Awesome TypeScript Types You Should Know

  Рет қаралды 74,084

Josh tried coding

Josh tried coding

7 ай бұрын

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

Пікірлер: 87
@sire_ns
@sire_ns 7 ай бұрын
I'll always appreciate these TS videos any day of the week
@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.
@froxx93
@froxx93 7 ай бұрын
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
@chrise.3114
@chrise.3114 7 ай бұрын
Great stuff Josh! Please never stop posting new content!
@shreyas0924
@shreyas0924 7 ай бұрын
We need more videos like these!! Great video buddy
@kesoBJJ
@kesoBJJ 7 ай бұрын
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.
@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
@ravinrod
@ravinrod 7 ай бұрын
Wow! These are good TypeScript tips. Thank you!
@aselivra
@aselivra 7 ай бұрын
Fantastic video, simple, well explained and to the point. Great examples 👍
@GambitVil
@GambitVil 7 ай бұрын
Really nice, short but with so many good and important things video.
@rahimco-su3sc
@rahimco-su3sc 7 ай бұрын
thanks a lot , we are constantly learning from your videos ! ,keep going
@njihiamark6926
@njihiamark6926 7 ай бұрын
great stuff Josh!
@luccaparadeda1985
@luccaparadeda1985 7 ай бұрын
Great video as always
@Nabulio85
@Nabulio85 7 ай бұрын
Great explanations, very well illustrated. Thanks
@Thassalocracy
@Thassalocracy 7 ай бұрын
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 7 ай бұрын
Bc it’s and interface 😂 not and object…
@mandokir
@mandokir 7 ай бұрын
Javascripters trying to understand object orientation.
@Netrole
@Netrole 7 ай бұрын
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 7 ай бұрын
​@@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 7 ай бұрын
it is useful in creating branded type
@jagdishpadeliya6050
@jagdishpadeliya6050 7 ай бұрын
Very helpful 🔥
@lakhveerchahal
@lakhveerchahal 5 ай бұрын
These are super cool tips. Thank you for sharing them
@nidhish6966
@nidhish6966 7 ай бұрын
This helped me a lot, Thanks !
@carlosricardoziegler2650
@carlosricardoziegler2650 7 ай бұрын
Great content :) I ❤ typescript
@petarkolev6928
@petarkolev6928 7 ай бұрын
Wow! Thanks, Josh 🍻🍻
@elliottchong
@elliottchong 7 ай бұрын
Super helpful! Thank you :)
@LeLaboDeHarry
@LeLaboDeHarry 7 ай бұрын
So useful thank you!
@cookieman.19
@cookieman.19 7 ай бұрын
This tutorial is valuable
@akarikev
@akarikev 7 ай бұрын
awesome pretty helpful!
@Leyksnal
@Leyksnal 7 ай бұрын
The best thing i have learnt today
@TheIpicon
@TheIpicon 7 ай бұрын
great video!
@maxwebstudio
@maxwebstudio 7 ай бұрын
Nice one ! Thanks !
@raymondmichael4987
@raymondmichael4987 7 ай бұрын
Thanks buddy 😊
@DevoidFX
@DevoidFX 4 ай бұрын
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 5 күн бұрын
The semantics of what the higher level types are defined as is relevant information.
@arifulhaque3236
@arifulhaque3236 7 ай бұрын
That's tips & tricks of Ts is time saving❤
@matthewbeardsley7004
@matthewbeardsley7004 7 ай бұрын
Yep, nice!! Thanks heaps!
@HG-wu6eb
@HG-wu6eb 7 ай бұрын
thank you let God bless you for your kind activity
@vorkosiganhs
@vorkosiganhs 6 ай бұрын
Amazing tips!! Thx a lot!
@JacksonDiKey
@JacksonDiKey 7 ай бұрын
About Exlude is mind-blowing! Tnx
@solosdev6946
@solosdev6946 21 күн бұрын
Thanks Josh helps alot for us :D
@HtetMyat79
@HtetMyat79 7 ай бұрын
Very greate video thanks
@dominikrodler8010
@dominikrodler8010 22 күн бұрын
One of the rare examples where a rather clickbaity sounding video really delivers 👍
@Renzo-of3yn
@Renzo-of3yn 7 ай бұрын
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.
@vaibhav5783
@vaibhav5783 7 ай бұрын
This is more complex than learning rust or c or go. Anyway great video :)
@user-og9np8hp1h
@user-og9np8hp1h 7 ай бұрын
It is usefull to me thanks!
@HectorGiudatto
@HectorGiudatto 7 ай бұрын
Master
@abdulgaffarabdulmalik4333
@abdulgaffarabdulmalik4333 2 ай бұрын
Do you mean no matter how nested they are or no matter the number of Joins? Great video btw
@T25de
@T25de 7 ай бұрын
Fuck yea Nice one ☝️
@muradmesteliyev5651
@muradmesteliyev5651 7 ай бұрын
I wonder will you have a video about a project with bun?
@lanskaba3668
@lanskaba3668 7 ай бұрын
Our brother always take us from darkness to light . Thank you Josh 🙏
@meka4996
@meka4996 7 ай бұрын
I think you can replace all "interface" with "type"
@latch909
@latch909 7 ай бұрын
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 7 ай бұрын
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 7 ай бұрын
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 7 ай бұрын
​@@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 6 ай бұрын
​@@gnack420Typescript shows you the inferred type when hovering the function name. No need for reading the code
@XxOsirisxX
@XxOsirisxX 3 ай бұрын
@@diegofernandocobacruz6508 The IDE does that, not TypeScript. Open it on a notepad and hover it over.
@shubhamrawat7895
@shubhamrawat7895 7 ай бұрын
type Person = keyof typeof obj type Return = ReturnType Partial Required type Omitted = Omit
@johnconnor9787
@johnconnor9787 2 ай бұрын
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?
@ahmedkhairydev
@ahmedkhairydev 7 ай бұрын
Great types, you just forgetting `Pick` 👀
@Ultrajuiced
@Ultrajuiced 7 ай бұрын
5:46 Errr... and what will be the return type of updateTodo again? 😝 Looks like somebody forgot another spread operator: ...fieldsToUpdate
@LabhamJain
@LabhamJain 3 ай бұрын
You should have added Pick as well since you showed omit
@tobiasnickel3750
@tobiasnickel3750 4 ай бұрын
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.
@realQuaz77
@realQuaz77 7 ай бұрын
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 5 ай бұрын
thats true one thing that can be done is "tsc --noEmit --incremental --watch" and that at least shows the errors in the console
@aashiqahmed5273
@aashiqahmed5273 4 ай бұрын
prettify is good one
@alasassi5889
@alasassi5889 7 ай бұрын
Do u think ai will replace us one day
@manit77
@manit77 3 ай бұрын
this is good to know, but you don't need any of this besides making things more complex and harder to debug.
@sammy709
@sammy709 7 ай бұрын
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 7 ай бұрын
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 7 ай бұрын
@@IneyeGabriel I know the feature is useful, but the example makes it more confusing
@laturdaily5110
@laturdaily5110 7 ай бұрын
ReturnType Awaited Partial Required Omit Exclude
@AlanMeile
@AlanMeile 3 ай бұрын
& {} wtf
@JakeAndDaddy
@JakeAndDaddy 5 ай бұрын
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 7 ай бұрын
Aaaaand the prettify type was fake :/
@greendsnow
@greendsnow 7 ай бұрын
sorry but this is not a high quality content...
@allone258
@allone258 7 ай бұрын
sorry but this is not a high quality comment
@juanps2721
@juanps2721 7 ай бұрын
That Prettify type makes the video high quality
@danieljanjanocha7178
@danieljanjanocha7178 7 ай бұрын
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 :)
This TypeScript Trick Blew my Mind
6:17
Josh tried coding
Рет қаралды 35 М.
Why use Type and not Interface in TypeScript
14:12
ByteGrad
Рет қаралды 185 М.
Этого От Него Никто Не Ожидал 😂
00:19
Глеб Рандалайнен
Рет қаралды 9 МЛН
I MADE A CARDBOARD SWING!#asmr
00:40
HAYATAKU はやたく
Рет қаралды 23 МЛН
Teenagers Show Kindness by Repairing Grandmother's Old Fence #shorts
00:37
Fabiosa Best Lifehacks
Рет қаралды 24 МЛН
TypeScript Generics are EASY once you know this
22:21
ByteGrad
Рет қаралды 117 М.
Has Generative AI Already Peaked? - Computerphile
12:48
Computerphile
Рет қаралды 114 М.
The Problem With UUIDs
6:36
Josh tried coding
Рет қаралды 64 М.
4 UI Design Tools I Can't Live Without
5:08
Josh tried coding
Рет қаралды 63 М.
Infer is easier than you think
13:38
Matt Pocock
Рет қаралды 83 М.
I Made This Open-Source Project
7:22
Josh tried coding
Рет қаралды 58 М.
We Need to Talk About Redis.
14:55
Josh tried coding
Рет қаралды 86 М.
Learn TypeScript Generics In 13 Minutes
12:52
Web Dev Simplified
Рет қаралды 195 М.
This UI Library is Kinda Sick
9:01
Josh tried coding
Рет қаралды 42 М.
Пленка или защитное стекло: что лучше?
0:52
Слава 100пудово!
Рет қаралды 1,1 МЛН
Samsung mobile phone waterproof display. samsung mobile phone digital s23ultra  #shorts
0:15
#Shorts Good idea for testing to show.
0:17
RAIN Gadgets
Рет қаралды 1,1 МЛН
phone charge game #viral #tranding #new #reels
0:18
YODHA GAMING RAAS
Рет қаралды 10 МЛН