ts如何重写类型?

我就想让test2的类型参数和test一样,然后就a的类型就变成string, 不能是number,我现在这样写是有问题的,会报错。 那种写法都行,求补充一个

type test ={
  a:number,
  b:string,
  c: array
}
type test2 = test & {
  a:string
}
阅读 5.1k
1 个回答
type test2 = Omit<test, 'a'> & {
  a:string
}
推荐问题