title: Typescript interface optional properties depending on other property
body: <p>Let's say we have the following Typescript <code>interface</code>:</p>
  <pre><code>interface Sample {
      key1: boolean;
      key2?: string;
      key3?: number;
  };
  </code></pre>
  <p>In this case, <code>key1</code> is always required, <code>key2</code> is always optional, while key3 should exist if <code>key1</code> is <code>true</code> and should not exist if <code>key1</code> is <code>false</code>. In another word, a key's occurrence depends on another key's value. How can we achieve this in Typescript?</p>