Skip to content

4.0.0

Latest
Compare
Choose a tag to compare
@ForbesLindesay ForbesLindesay released this 27 Apr 15:34
5a240f6

Breaking Changes

  • Use PromiseLike instead of Promise in TypeScript (#40)

    This is only a breaking change for TypeScript users.

    In the following code:

    function foo(x: PromiseLike<string> | string) {
      if (isPromise(x)) {
        return x;
      } else {
        return Promise.resolve(x);
      }
    }

    TypeScript would previously have incorrectly inferred foo as returning Promisestring>when in fact it returnsPromiseLikestring>. The latest version fixes this. If you instead had the following code, it should work exactly the same as before:

    function foo(x: Promise<string> | string) {
      if (isPromise(x)) {
        return x;
      } else {
        return Promise.resolve(x);
      }
    }

    This update is to reflect the fact that is-promise does "duck" typing, rather than an instanceof check.