Что такое template literal types в TypeScript?

Senior
216 просмотров
AFK Offer AI

Template literal types позволяют создавать строковые типы через шаблоны: type EventName = on${Capitalize}. type CssValue = ${number}px | ${number}em. Комбинируются с union: type Direction = "top" | "bottom"; type Position = ${Direction}-${"left" | "right"} = "top-left" | "top-right" | "bottom-left" | "bottom-right". В Node.js полезны для type-safe event names, CSS-in-JS, API endpoint типизации.

Следующий вопрос

Как использовать jest --projects для разных типов тестов?