title: Strongly typed deep equal assertion with TypeScript and Chai
body: <p>I have a TypeScript function that returns a type <code>Foo</code>:</p>
  
  <pre><code>interface Foo {
    bar: string;
    baz: string;
  }
  
  function getFoo(): Foo {
    return {
      bar: 'hello',
      baz: 'world',
    };
  }
  
  // Chai Assertion
  it('Should return a Foo', () =&gt; {
    expect(getFoo()).to.deep.equal({
      bar: 'hello',
      baz: 'world',
    });
  })
  </code></pre>
  
  <p>When I change the <code>Foo</code> interface, my <code>getFoo()</code> function produces a TypeScript error:</p>
  
  <pre><code>interface Foo {
    bar: number;  // change these to numbers instead
    baz: number;
  }
  
  function getFoo(): Foo {
    // Compile time error! Numbers aren't strings!
    return {
      bar: 'hello',
      baz: 'world',
    };
  }
  </code></pre>
  
  <p>However, my Mocha test does not trigger a compile time error!</p>
  
  <p>Is there a type-safe way of doing <code>expect().to.deep.equal()</code>? Something like:</p>
  
  <pre><code>// Strawman for how I'd like to do type-safety for deep equality assertions,
  // though this generic signature still seems unnecessary?
  expect&lt;Foo&gt;(getFoo()).to.deep.equal({
    bar: 'hello',
    baz: 'world',
  });
  </code></pre>