title: Pacts: How to match a sum / union type?
body: <p>I have an api endpoint which shall return an array of a sum type. How can I write an appropriate matcher for it in pacts (javascript version, consumer site)?</p>
  <p>Example: Imagine we have the endpoint <code>/api/events</code> which returns a list of dictionaries each representing an event. Let's say we have two different types of events (which might be several in practise):</p>
  <pre class="lang-js prettyprint-override"><code>interface ContentAddedEvent {
    type: &quot;ContentAdded&quot;
    newContent: string
  }
  
  interface UserRegisteredEvent {
    type: &quot;Userregistered&quot;
    username: string
  }
  
  type Event = ContentAddedEvent | UserRegisteredEvent
  </code></pre>
  <p><code>/api/events</code> returns an array of the type <code>Event[]</code>. How do I write a matcher for it? I have not found a good example at <a href="https://docs.pact.io/implementation_guides/javascript/readme#matching" rel="nofollow noreferrer">https://docs.pact.io/implementation_guides/javascript/readme#matching</a> how I can archive it...</p>