title: Disallow call with any
body: <p>Consider following function overloads:</p>
  
  <pre><code>function f(key: undefined);
  function f(key: string | undefined, value: object | undefined);
  </code></pre>
  
  <p>I want to make eligible calls with single explicit undefined <code>f(undefined)</code>, but require two arguments for all other cases. And overloads above work fine, until I pass a variable with type <code>any</code> - seems like <code>any</code> can be casted to <code>undefined</code> (yes, it seems logical as it is any).</p>
  
  <p><strong>How can I disallow call with single <code>any</code> argumnent?</strong></p>
  
  <hr>
  
  <p>Full <a href="https://www.typescriptlang.org/play/#src=function%20f(key%3A%20undefined)%3B%0D%0Afunction%20f(key%3A%20string%20%7C%20undefined%2C%20value%3A%20object%20%7C%20undefined)%3B%0D%0A%0D%0Afunction%20f(key%3A%20string%20%7C%20undefined%2C%20value%3F%3A%20object%20%7C%20undefined)%20%7B%0D%0A%20%20%20%20console.log(key%2C%20value)%3B%0D%0A%7D%0D%0A%0D%0A%2F%2F%20No%20errors%20-%20RIGHT%0D%0Af(undefined)%3B%0D%0Af(%22%22%2C%20%7B%7D)%3B%0D%0Af(%22%22%2C%20undefined)%3B%0D%0Af(undefined%2C%20undefined)%3B%0D%0Af(undefined%2C%20%7B%7D)%3B%0D%0A%0D%0A%2F%2F%20Errors%20-%20RIGHT%0D%0Af(%22%22)%3B%0D%0A%0D%0A%2F%2F%20No%20errors%20-%20WRONG%0D%0Adeclare%20var%20x%3A%20any%3B%0D%0Af(x)%3B" rel="noreferrer">demo code</a>:</p>
  
  <pre><code>function f(key: undefined);
  function f(key: string | undefined, value: object | undefined);
  
  function f(key: string | undefined, value?: object | undefined) {
      console.log(key, value);
  }
  
  // No errors - RIGHT
  f(undefined);
  f("", {});
  f("", undefined);
  f(undefined, undefined);
  f(undefined, {});
  
  // Errors - RIGHT
  f("");
  
  // No errors - WRONG
  declare var x: any;
  f(x);
  </code></pre>