【发布时间】:2021-03-09 15:07:50
【问题描述】:
打字稿中有什么方法可以动态连接键名/动态连接字符串类型吗?我的意思是:
type JoinString<A extends string, B extends string> = /*some magic*/
const example = {
foo: "b",
bar: "c"
}
type GetAnotherKeys<T> = {
JoinString<[TKey in keyof T], "_">: T[Tkey]
}
type Result = GetAnotherKeys<typeof example>;
/*
Result ={
foo_:string
bar_:string
}
*/
【问题讨论】:
标签: javascript string typescript types