【发布时间】:2021-08-28 04:26:49
【问题描述】:
type B = {
c: string
}
type T = {
a: string
b: B
}
我想让T2看起来像
type T2 = {
a: string
['b' or 'prefixB']: B
}
基本上我希望 T 具有 a 和 b 或 prefixB 属性 - 你知道如何以简单的方式做到这一点吗?类似于两者之一的东西
【问题讨论】:
-
可以查看本题第二个答案stackoverflow.com/questions/37688318/…
-
这能回答你的问题吗? TypeScript a | b allows combination of both
标签: typescript typescript-typings