use Partial in nested property with typescript

前端 未结 4 973
慢半拍i
慢半拍i 2020-12-13 13:13

Say I have a type like this;

interface State {
  one: string,
  two: {
    three: {
      four: string
    },
    five: string
  }
}

I make

4条回答
  •  既然无缘
    2020-12-13 13:21

    Try to exclude the nested Property, and add it again as Partial:

    interface Foo {
        someName: Partial & { lvl2Partial: Partial }>
    }
    

提交回复
热议问题