title: Type functions that can be promsified
body: <p>I'm working on adding separate types to <a href="https://github.com/edin-m/node-vagrant" rel="nofollow noreferrer">node-vagrant</a> NPM library to use in Typescript, to be contributed under <a href="https://github.com/DefinitelyTyped/DefinitelyTyped" rel="nofollow noreferrer">DefinitelyTyped</a>. However, one of the methods of the library is <a href="https://github.com/edin-m/node-vagrant/blob/master/src/index.js#L134-L150" rel="nofollow noreferrer">promisify</a> which makes all other functions in the library then return a promise instead of a callback. </p>
  
  <p>Given that I only have control over adding the typing (<code>.d.ts</code>) file, is there a way to indicate to <code>tsc</code> that the result of calling that custom promisify function is on the functions, or some other mechanism of dynamism? Or is it just that I provide typings for both usages of the function, and the user has to just make sure they choose appropriately?</p>
  
  <p>A minimal example would be for the JS file to be:</p>
  
  <pre><code>module.exports.foo = function (cb) {
      cb(null, 'foo');
  };
  
  module.exports.promisify = function () {
    module.exports.foo = util.promisify(module.exports.foo);
  }
  </code></pre>
  
  <p>and the typing (in a <code>.d.ts</code> file) I've got is:</p>
  
  <pre><code>export function foo(cb: (err: null | string, out: string) =&gt; void): void;
  export function promisify(): void;
  </code></pre>
  
  <p>Now, when I use the typings:</p>
  
  <pre><code>import foo = require('foo');
  
  foo.foo((err, out) =&gt; { console.log(err, out); });
  foo.promisify();
  foo.foo().then(out =&gt; console.log(out)).catch(err =&gt; console.log(err));
  </code></pre>
  
  <p>where the last line throws an error with the TSC. Is the solution to just declare both callback and the promise on the function signature and have the end user appropriately decide on which one to use or is there some mechanism in TypeScript to dynamically toggle the return info on a function?</p>
  
  <p>From the above, is the final verdict just doing:</p>
  
  <pre><code>export function foo(): Promise&lt;string&gt;;
  export function foo(cb: (err: null | string, out: string) =&gt; void): void;
  </code></pre>
  
  <p>and and as mentioned above, just letting the end-user figure out if they want the callback or the promise?</p>