Destructure/access a property that may or may not exist on an object union type

前端 未结 0 724
太阳男子
太阳男子 2021-01-16 03:41

I get the following errors:

type Union = { type: "1"; foo: string } | { type: "2"; bar: number };

function doSomething = (object: Union)          


        
相关标签:
回答
  • 消灭零回复
提交回复
热议问题