Telegram Group & Telegram Channel
🖥 Что делает конструкция [K in Status]: \[${K}]``?

Вот код из видео, который вызывает вопросы:


type Status = 'success' | 'error' | 'loading';

type StatusWithBrackets = {
[K in Status]: `[${K}]`
}[Status];


💡 Что здесь происходит?

1️⃣ **[K in Status]: \[${K}]`** Мы создаем объект на уровне типов. Для каждого значения из Status ('success' | 'error' | 'loading'`) генерируются ключи и их значения. Например:

{
success: "[success]",
error: "[error]",
loading: "[loading]"
}


2️⃣ [Status]
Эта часть "вытаскивает" все значения, которые соответствуют ключам Status.
То есть:

"[success]" | "[error]" | "[loading]"


🛠️ Итог: StatusWithBrackets превращается в объединение строк:
"[success]" | "[error]" | "[loading]".


#typescript
Please open Telegram to view this post
VIEW IN TELEGRAM



group-telegram.com/reactify_IT/1376
Create:
Last Update:

🖥 Что делает конструкция [K in Status]: \[${K}]``?

Вот код из видео, который вызывает вопросы:


type Status = 'success' | 'error' | 'loading';

type StatusWithBrackets = {
[K in Status]: `[${K}]`
}[Status];


💡 Что здесь происходит?

1️⃣ **[K in Status]: \[${K}]`** Мы создаем объект на уровне типов. Для каждого значения из Status ('success' | 'error' | 'loading'`) генерируются ключи и их значения. Например:

{
success: "[success]",
error: "[error]",
loading: "[loading]"
}


2️⃣ [Status]
Эта часть "вытаскивает" все значения, которые соответствуют ключам Status.
То есть:

"[success]" | "[error]" | "[loading]"


🛠️ Итог: StatusWithBrackets превращается в объединение строк:
"[success]" | "[error]" | "[loading]".


#typescript

BY Reactify | Frontend Разработка


Warning: Undefined variable $i in /var/www/group-telegram/post.php on line 260

Share with your friend now:
group-telegram.com/reactify_IT/1376

View MORE
Open in Telegram


Telegram | DID YOU KNOW?

Date: |

"Your messages about the movement of the enemy through the official chatbot … bring new trophies every day," the government agency tweeted. "He has to start being more proactive and to find a real solution to this situation, not stay in standby without interfering. It's a very irresponsible position from the owner of Telegram," she said. The account, "War on Fakes," was created on February 24, the same day Russian President Vladimir Putin announced a "special military operation" and troops began invading Ukraine. The page is rife with disinformation, according to The Atlantic Council's Digital Forensic Research Lab, which studies digital extremism and published a report examining the channel. Lastly, the web previews of t.me links have been given a new look, adding chat backgrounds and design elements from the fully-features Telegram Web client. Stocks closed in the red Friday as investors weighed upbeat remarks from Russian President Vladimir Putin about diplomatic discussions with Ukraine against a weaker-than-expected print on U.S. consumer sentiment.
from br


Telegram Reactify | Frontend Разработка
FROM American