0

for example, I have a function called foo.

Either foo({a: bar}) or foo({b: baz}) is valid but it cannot be foo({}) or foo({a: bar, b: baz})

How do I define the types for this function to achieve this?

Joji
  • 4,703
  • 7
  • 41
  • 86
  • 5
    Does this answer your question? [Does Typescript support mutually exclusive types?](https://stackoverflow.com/questions/42123407/does-typescript-support-mutually-exclusive-types) – Adam Kern Nov 04 '20 at 02:37
  • Does this answer your question? [typescript interface require one of two properties to exist](https://stackoverflow.com/questions/40510611/typescript-interface-require-one-of-two-properties-to-exist) – ford04 Nov 04 '20 at 07:56

0 Answers0