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
 
zizaco profile image
Zizaco β€’
  1. Union Types with Exhaustive Checks is gold!
Collapse
 
jagroop2001 profile image
Jagroop Singh β€’

Thanks @zizaco

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
 
itsmeseb profile image
sebkolind β€’

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

Collapse
 
jagroop2001 profile image
Jagroop Singh β€’

Thanks @itsmeseb

Collapse
 
boby900 profile image
Boby Tiwari β€’

πŸ’―

Collapse
 
jagroop2001 profile image
Jagroop Singh β€’

Thanks @boby900

Collapse
 
works profile image
Web β€’

nice posts about typescript !!

Collapse
 
jagroop2001 profile image
Jagroop Singh β€’

Thanks !!

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 β€’

??