79466215

Date: 2025-02-25 10:43:48
Score: 2
Natty:
Report link

So, after some researching and read this post https://www.reddit.com/r/typescript/comments/1bjgdky/union_types_of_objects_issue/, I made this:

type A = {
  propA1: string
  propA2: string
}

type B = {
  propB1: string
  propB2: string
}



const f = (arg: A & { [key in keyof B]?: never } | B & { [key in keyof A]?: never }) => { }

f({ propA1: 'propA1', propA2: 'propA2', propB1: '' }) // error

playground

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (1):
Posted by: Uzakov Nikita