title: TypeScript: an interface property requires another property to be true
body: <p>How can I define keys: <code>a, b, c, bar</code> as <strong>undefined/null/optional</strong> type if <strong>foo is false</strong>? In other words, I need these properties to be <strong>mandatory</strong> only if <strong>foo is true</strong>.</p>
  <pre><code>interface ObjectType {
    foo: boolean;
    a: number;
    y: string;
    c: boolean;
    bar?: { x: number; y: string; z: boolean };
  }
  </code></pre>
  <p>Thanks! :)</p>