Video wird geladen...

Video konnte nicht geladen werden

Zur Startseite

🔥 TypeScript Tip 🔥 Omit and Pick are the gateway to understanding type-level programming. They let you start deriving types, instead of redeclaring them.

232,311 Aufrufe • vor 3 Jahren •via X (Twitter)

10 Kommentare

Profilbild von Fernando Rojo
Fernando Rojovor 3 Jahren

i like combining them to add type suggestions to Omit itself: type Omitted = keyof Pick<User, ‘role’> type WithoutRole = Omit<User, Omitted>

Profilbild von Matt Pocock
Matt Pocockvor 3 Jahren

Or type StrictOmit<T, K extends keyof T> = Omit<T, K>;

Profilbild von Sumit | Frontend
Sumit | Frontendvor 3 Jahren

Which tool do you use to edit these videos? 🥺🥺🥺 please Matt

Profilbild von calebcodes
calebcodesvor 3 Jahren

Very interesting. Any reason to prefer one of these over "traditional" inheritance (extending interfaces to add fields)? I can see how there are some semantic benefits to Pick/Omit, but I wonder if they'd lead to some bad practices from an OOP perspective 🤔

Profilbild von Roman Holubenko
Roman Holubenkovor 3 Jahren

Very useful, but now I have a question: what better way to structure types on the project would you suggest? Making a single file named "types" and export all needed types from there, or writing types inside working files where you use them?

Profilbild von Jimmy Thompson
Jimmy Thompsonvor 3 Jahren

Definitely a powerful tool, but should be used with care IMO. These patterns crept into our codebase and caused an explosion in types, each used only once. As much as types are for type safety, they're to help you describe your domain. Meaningless types are as bad as no types.

Profilbild von Uberto Barbini @ramtop.bsky.social
Uberto Barbini @ramtop.bsky.socialvor 3 Jahren

I wish we could do something like this in kotlin... :(

Profilbild von fuko
fukovor 3 Jahren

short and sweet! I particularly love this format, thanks for the vid! 😊

Profilbild von harpaljadeja.eth (evm/acc) 🇮🇳
harpaljadeja.eth (evm/acc) 🇮🇳vor 3 Jahren

Damn your animator is already working!

Profilbild von Edun Omatseye 🔥
Edun Omatseye 🔥vor 3 Jahren

just only natural to do a follow up video on Extract<> and Exclude<> 🤞

Ähnliche Videos