title: Using Thenable Interfaces with ES6 Promises in TypeScript
body: <p>Some libraries offer <code>Thenable</code> Interface typings f.e. <a href="https://github.com/epoberezkin/ajv/blob/master/lib/ajv.d.ts#L110" rel="nofollow noreferrer">AJV</a>.<br>
  There is something I don't understand about them. Given this minimal code </p>
  
  <pre><code>const foo: Ajv.Thenable&lt;boolean&gt; = new Promise&lt;boolean&gt;((resolve, reject) =&gt; {
    if ("condition")
      resolve(true)
  
    reject("Nope")
  })
  </code></pre>
  
  <p>the TypeScript compiler throws an error which I can't wrap my head around. </p>
  
  <pre><code>error TS2322: Type 'Promise&lt;boolean&gt;' is not assignable to type 'Thenable&lt;boolean&gt;'.
    Types of property 'then' are incompatible.
      Type '&lt;TResult1 = boolean, TResult2 = never&gt;(onfulfilled?: ((value: boolean) =&gt; TResult1 | PromiseLike&lt;...' is not assignable to type '&lt;U&gt;(onFulfilled?: ((value: boolean) =&gt; U | Thenable&lt;U&gt;) | undefined, onRejected?: ((error: any) =...'.
        Types of parameters 'onfulfilled' and 'onFulfilled' are incompatible.
          Type '((value: boolean) =&gt; U | Thenable&lt;U&gt;) | undefined' is not assignable to type '((value: boolean) =&gt; U | PromiseLike&lt;U&gt;) | null | undefined'.
            Type '(value: boolean) =&gt; U | Thenable&lt;U&gt;' is not assignable to type '((value: boolean) =&gt; U | PromiseLike&lt;U&gt;) | null | undefined'.
              Type '(value: boolean) =&gt; U | Thenable&lt;U&gt;' is not assignable to type '(value: boolean) =&gt; U | PromiseLike&lt;U&gt;'.
                Type 'U | Thenable&lt;U&gt;' is not assignable to type 'U | PromiseLike&lt;U&gt;'.
                  Type 'Thenable&lt;U&gt;' is not assignable to type 'U | PromiseLike&lt;U&gt;'.
                    Type 'Thenable&lt;U&gt;' is not assignable to type 'PromiseLike&lt;U&gt;'.
                      Types of property 'then' are incompatible.
                        Type '&lt;U&gt;(onFulfilled?: ((value: U) =&gt; U | Thenable&lt;U&gt;) | undefined, onRejected?: ((error: any) =&gt; U | ...' is not assignable to type '&lt;TResult1 = U, TResult2 = never&gt;(onfulfilled?: ((value: U) =&gt; TResult1 | PromiseLike&lt;TResult1&gt;) |...'.
                          Types of parameters 'onFulfilled' and 'onfulfilled' are incompatible.
                            Type '((value: U) =&gt; TResult1 | PromiseLike&lt;TResult1&gt;) | null | undefined' is not assignable to type '((value: U) =&gt; TResult2 | Thenable&lt;TResult2&gt;) | undefined'.
                              Type 'null' is not assignable to type '((value: U) =&gt; TResult2 | Thenable&lt;TResult2&gt;) | undefined'.
  </code></pre>
  
  <p>Where exactly does the compiler think a <a href="https://github.com/Microsoft/TypeScript/blob/2b61d18996c182b7de8ef2a9367210a70e3d4031/src/lib/es2015.promise.d.ts#L13" rel="nofollow noreferrer">TypeScripts ES6 Promise</a> will return <code>null</code> (if thats the actual error)?<br>
  And why <strong>do</strong> some libraries (bluebird, rsvp, ember, ...) use <code>Thenable</code> instead of <code>Promise</code>/<code>PromiseLike</code>?</p>