Jul*_*leZ 2 javascript typescript
我想知道是否有一种方法可以连接两个打字稿类型作为一个例子:
type Size = 'xl' | 'xxl' ...;
let textSize: 'text-' & Size;
// So my type is something like : 'text-xl' | 'text-xxl'
Run Code Online (Sandbox Code Playgroud)
通过使用模板文字类型。
type Size = 'xl' | 'xxl';
type TextSizeType = `text-${Size}`;
Run Code Online (Sandbox Code Playgroud)
TSTextSizeType决定
type TextSizeType = "text-xl" | "text-xxl"
Run Code Online (Sandbox Code Playgroud)
这听起来像你想要的。
| 归档时间: |
|
| 查看次数: |
452 次 |
| 最近记录: |