小编Xia*_*yun的帖子

我可以在 TypeScript 中切片文字类型吗

在 TypeScript 中,当我想编辑文字类型时,它可以工作。

type Old = "helloWorld"
//   ^? "helloWorld"
type New = `${Old}New`
//   ^? "helloWorldNew"
Run Code Online (Sandbox Code Playgroud)

但我怎样才能做到这一点。

type Old = "helloWorld"
//   ^? "helloWorld"
type New = Slice<"helloWorld",5> // < Is it possible
//   ^? "World"
Run Code Online (Sandbox Code Playgroud)

types typescript

4
推荐指数
1
解决办法
2590
查看次数

标签 统计

types ×1

typescript ×1