Typescript Unions based on property inside nested object
问题 I'm trying to create a Union Type based on a nested property in my object. See the example below: type Foo = { abilities: { canManage: boolean } } type Bar = { abilities: { canManage: boolean } extraProp: number } type Condition1 = { abilities: { canManage: true } } & Bar type Condition2 = { abilities: { canManage: false } } & Foo type TotalData = Condition1 | Condition2 const data: TotalData = { abilities: { canManage: false, // if canManage is false, TS should complain when I add the