【发布时间】:2022-01-09 20:14:11
【问题描述】:
我想知道是否有一种方法可以连接两种打字稿类型作为一个例子:
type Size = 'xl' | 'xxl' ...;
let textSize: 'text-' & Size;
// So my type is something like : 'text-xl' | 'text-xxl'
【问题讨论】:
标签: javascript typescript
我想知道是否有一种方法可以连接两种打字稿类型作为一个例子:
type Size = 'xl' | 'xxl' ...;
let textSize: 'text-' & Size;
// So my type is something like : 'text-xl' | 'text-xxl'
【问题讨论】:
标签: javascript typescript
type Size = 'xl' | 'xxl';
type TextSizeType = `text-${Size}`;
TS 将TextSizeType 解析为
type TextSizeType = "text-xl" | "text-xxl"
这听起来像你想要的。
【讨论】: