7 Awesome TypeScript Types You Should Know

  Рет қаралды 75,167

Josh tried coding

Josh tried coding

8 ай бұрын

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

Пікірлер: 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.
@sire_ns
@sire_ns 8 ай бұрын
I'll always appreciate these TS videos any day of the week
@dominikrodler8010
@dominikrodler8010 Ай бұрын
One of the rare examples where a rather clickbaity sounding video really delivers 👍
@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 21 күн бұрын
The semantics of what the higher level types are defined as is relevant information.
@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
@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 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.
@Nabulio85
@Nabulio85 7 ай бұрын
Great explanations, very well illustrated. Thanks
@aselivra
@aselivra 7 ай бұрын
Fantastic video, simple, well explained and to the point. Great examples 👍
@GambitVil
@GambitVil 8 ай бұрын
Really nice, short but with so many good and important things video.
@chrise.3114
@chrise.3114 8 ай бұрын
Great stuff Josh! Please never stop posting new content!
@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
@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 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
@luccaparadeda1985
@luccaparadeda1985 8 ай бұрын
Great video as always
@njihiamark6926
@njihiamark6926 8 ай бұрын
great stuff Josh!
@nidhish6966
@nidhish6966 8 ай бұрын
This helped me a lot, Thanks !
@vorkosiganhs
@vorkosiganhs 6 ай бұрын
Amazing tips!! Thx a lot!
@carlosricardoziegler2650
@carlosricardoziegler2650 8 ай бұрын
Great content :) I ❤ typescript
@elliottchong
@elliottchong 8 ай бұрын
Super helpful! Thank you :)
@solosdev6946
@solosdev6946 Ай бұрын
Thanks Josh helps alot for us :D
@LeLaboDeHarry
@LeLaboDeHarry 8 ай бұрын
So useful thank you!
@petarkolev6928
@petarkolev6928 8 ай бұрын
Wow! Thanks, Josh 🍻🍻
@maxwebstudio
@maxwebstudio 8 ай бұрын
Nice one ! Thanks !
@TheIpicon
@TheIpicon 8 ай бұрын
great video!
@Leyksnal
@Leyksnal 8 ай бұрын
The best thing i have learnt today
@jagdishpadeliya6050
@jagdishpadeliya6050 8 ай бұрын
Very helpful 🔥
@JacksonDiKey
@JacksonDiKey 7 ай бұрын
About Exlude is mind-blowing! Tnx
@raymondmichael4987
@raymondmichael4987 8 ай бұрын
Thanks buddy 😊
@arifulhaque3236
@arifulhaque3236 8 ай бұрын
That's tips & tricks of Ts is time saving❤
@akarikev
@akarikev 8 ай бұрын
awesome pretty helpful!
@HG-wu6eb
@HG-wu6eb 8 ай бұрын
thank you let God bless you for your kind activity
@HtetMyat79
@HtetMyat79 8 ай бұрын
Very greate video thanks
@matthewbeardsley7004
@matthewbeardsley7004 8 ай бұрын
Yep, nice!! Thanks heaps!
@cookieman.19
@cookieman.19 7 ай бұрын
This tutorial is valuable
@vaibhav5783
@vaibhav5783 8 ай бұрын
This is more complex than learning rust or c or go. Anyway 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.
@user-og9np8hp1h
@user-og9np8hp1h 8 ай бұрын
It is usefull to me thanks!
@abdulgaffarabdulmalik4333
@abdulgaffarabdulmalik4333 3 ай бұрын
Do you mean no matter how nested they are or no matter the number of Joins? Great video btw
@kilo.ironblossom
@kilo.ironblossom 15 күн бұрын
Prettify is now a vscode extension
@muradmesteliyev5651
@muradmesteliyev5651 8 ай бұрын
I wonder will you have a video about a project with bun?
@lanskaba3668
@lanskaba3668 8 ай бұрын
Our brother always take us from darkness to light . Thank you Josh 🙏
@ahmedkhairydev
@ahmedkhairydev 7 ай бұрын
Great types, you just forgetting `Pick` 👀
8 ай бұрын
Master
@T25de
@T25de 8 ай бұрын
Fuck yea Nice one ☝️
@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 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 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.
@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.
@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?
@shubhamrawat7895
@shubhamrawat7895 8 ай бұрын
type Person = keyof typeof obj type Return = ReturnType Partial Required type Omitted = Omit
@Ultrajuiced
@Ultrajuiced 8 ай бұрын
5:46 Errr... and what will be the return type of updateTodo again? 😝 Looks like somebody forgot another spread operator: ...fieldsToUpdate
@meka4996
@meka4996 8 ай бұрын
I think you can replace all "interface" with "type"
@LabhamJain
@LabhamJain 4 ай бұрын
You should have added Pick as well since you showed omit
@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 6 ай бұрын
thats true one thing that can be done is "tsc --noEmit --incremental --watch" and that at least shows the errors in the console
@alasassi5889
@alasassi5889 8 ай бұрын
Do u think ai will replace us one day
@aashiqahmed5273
@aashiqahmed5273 5 ай бұрын
prettify is good one
@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.
@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
@laturdaily5110
@laturdaily5110 8 ай бұрын
ReturnType Awaited Partial Required Omit Exclude
@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.
@AlanMeile
@AlanMeile 3 ай бұрын
& {} wtf
@NatoBoram
@NatoBoram 7 ай бұрын
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 :)
This TypeScript Trick Blew my Mind
6:17
Josh tried coding
Рет қаралды 36 М.
Why use Type and not Interface in TypeScript
14:12
ByteGrad
Рет қаралды 187 М.
Why? 😭 #shorts by Leisi Crazy
00:16
Leisi Crazy
Рет қаралды 40 МЛН
Can You Draw The PERFECT Circle?
00:57
Stokes Twins
Рет қаралды 84 МЛН
Generics: The most intimidating TypeScript feature
18:19
Matt Pocock
Рет қаралды 160 М.
Everyone's talking about gql.tada
5:06
Matt Pocock
Рет қаралды 41 М.
Type your functions in TypeScript and SAVE TIME
8:31
ThePrimeTime
Рет қаралды 47 М.
Infer is easier than you think
13:38
Matt Pocock
Рет қаралды 84 М.
7 React Lessons I Wish I Knew Earlier
7:30
Code Bootcamp
Рет қаралды 47 М.
This is TypeScript's Most Powerful Keyword
4:22
Josh tried coding
Рет қаралды 11 М.
Node.js is a serious thing now… (2023)
8:18
Code With Ryan
Рет қаралды 624 М.
Why Signals Are Better Than React Hooks
16:30
Web Dev Simplified
Рет қаралды 447 М.
A4 Reset to zero
0:26
STYLE YT
Рет қаралды 17 М.
Samsung or iPhone
0:19
rishton vines😇
Рет қаралды 8 МЛН
XL-Power Best For Audio Call 📞 Mobile 📱
0:42
Tech Official
Рет қаралды 768 М.