DEV Community

Cover image for 20 TypeScript Tricks Every Developer Should Know πŸš€

20 TypeScript Tricks Every Developer Should Know πŸš€

Jagroop Singh on October 23, 2024

TypeScript is a powerhouse for modern JavaScript development, bringing type safety and advanced features to the table. While many developers know ...
Collapse
 
hraifi profile image
sewiko

I just discovered the Partial<T> utility, and I think it’s an impressive implementation. Instead of relying on a any keyword, it provides a clean and flexible way to create objects with optional properties.
Thanks for sharing.

Collapse
 
jagroop2001 profile image
Jagroop Singh

Thanks @hraifi

Collapse
 
pengeszikra profile image
Peter Vivo • Edited

Great collection, thx!

One more trick :: in my opinion jsDoc is better than Typescript

Collapse
 
jagroop2001 profile image
Jagroop Singh

Thanks! I appreciate your perspective @pengeszikra

Collapse
 
john12 profile image
john

Thanks for sharing !!
11. Extract and Exclude to Refine Types is very new to me and become my personal favorite.

Collapse
 
jagroop2001 profile image
Jagroop Singh

Thanks @john12

Collapse
 
itsmeseb profile image
sebkolind | β›Ί Tent.js

Great post! There are definitely some useful tips and tricks included!

Collapse
 
jagroop2001 profile image
Jagroop Singh

Thanks @itsmeseb

Collapse
 
vindexus profile image
Colin Kierans

Thanks for these! Extract has been useful at my job for dealing with unions that are referenced in other semi related types.

Collapse
 
jagroop2001 profile image
Jagroop Singh

Your welcome !!

Collapse
 
works profile image
Web

nice posts about typescript !!

Collapse
 
jagroop2001 profile image
Jagroop Singh

Thanks !!

Collapse
 
zizaco profile image
Zizaco
  1. Union Types with Exhaustive Checks is gold!
Collapse
 
jagroop2001 profile image
Jagroop Singh

Thanks @zizaco

Collapse
 
boby900 profile image
Boby Tiwari

πŸ’―

Collapse
 
jagroop2001 profile image
Jagroop Singh

Thanks @boby900

Collapse
 
nozibul_islam_113b1d5334f profile image
Nozibul Islam

I'm glad you found the TS shortcuts helpful! If you need more specific shortcuts or tricks, especially for any particular task in TS or a particular framework, feel free to ask. It’s a pleasure to share helpful insights!

Collapse
 
jagroop2001 profile image
Jagroop Singh

??