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 Разработка

❌Photos not found?❌Click here to update cache.


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: |

He floated the idea of restricting the use of Telegram in Ukraine and Russia, a suggestion that was met with fierce opposition from users. Shortly after, Durov backed off the idea. Elsewhere, version 8.6 of Telegram integrates the in-app camera option into the gallery, while a new navigation bar gives quick access to photos, files, location sharing, and more. Perpetrators of such fraud use various marketing techniques to attract subscribers on their social media channels. To that end, when files are actively downloading, a new icon now appears in the Search bar that users can tap to view and manage downloads, pause and resume all downloads or just individual items, and select one to increase its priority or view it in a chat. In this regard, Sebi collaborated with the Telecom Regulatory Authority of India (TRAI) to reduce the vulnerability of the securities market to manipulation through misuse of mass communication medium like bulk SMS.
from tw


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