Quick: Mapped Types in TypeScript #typescript #typescripttutorial #coding #programming

preview_player
Показать описание
Basic introduction of Mapped Types in TypeScript
Рекомендации по теме
Комментарии
Автор

You make amazing shorts man… simplification to a T

OverrideTips
Автор

This is very useful, thanks!

Here's something else I recently came across. Maybe you want to make a short about it?
type Options = { something: string };
const options = { something: "test" } as const satisfies Options;

options.something // "test" string literal

Some other ideas is to make videos about string literals in typescripts type system. That's where things get really interesting and complex!

ericb
Автор

I have a very educational challenge for you if you're up for it!

Given any arbitrarily deeply nested object type like this:
{ a: { b: any }, c: any}
return a union of all valid property accesses as string literals. So for the above example that would be:
"a" | "a.b" | "c"

I had to use this once when I used a data table component from Nuxt component library, so it's actually useful as well as very educational!

I hope you try this out, and if you need any hints or have any questions, I would love to answer them!

ericb
visit shbcf.ru