【发布时间】:2018-03-13 21:53:41
【问题描述】:
我正在尝试为这个函数写一个签名:
export function objToArray(obj){
let ret = [];
for(const key of Object.keys(obj)){
ret.push(Object.assign({objKey: key.toString()}, obj[key]));
}
return ret;
}
因此,对于包含 U 类型值的 T 类型对象,我想返回 Array<U & {objKey: string}>。我不知道如何用打字稿来做到这一点。
【问题讨论】:
标签: typescript typescript-typings typescript2.0