Загрузка видео...

Не удалось загрузить видео

На главную

🔥 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 просмотров • 3 лет назад •via X (Twitter)

Комментарии: 10

Фото профиля Fernando Rojo
Fernando Rojo3 лет назад

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

Фото профиля Matt Pocock
Matt Pocock3 лет назад

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

Фото профиля Sumit | Frontend
Sumit | Frontend3 лет назад

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

Фото профиля calebcodes
calebcodes3 лет назад

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 🤔

Фото профиля Roman Holubenko
Roman Holubenko3 лет назад

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?

Фото профиля Jimmy Thompson
Jimmy Thompson3 лет назад

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.

Фото профиля Uberto Barbini @ramtop.bsky.social
Uberto Barbini @ramtop.bsky.social3 лет назад

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

Фото профиля fuko
fuko3 лет назад

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

Фото профиля harpaljadeja.eth (evm/acc) 🇮🇳
harpaljadeja.eth (evm/acc) 🇮🇳3 лет назад

Damn your animator is already working!

Фото профиля Edun Omatseye 🔥
Edun Omatseye 🔥3 лет назад

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

Похожие видео