Releases: then/is-promise
4.0.0
Breaking Changes
-
Use
PromiseLike
instead ofPromise
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 returningPromise
string>when in fact it returns
PromiseLikestring>
. 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 aninstanceof
check.
3.0.0
Breaking Changes
-
Restricted "exports" in package.json (for node 14+) (#30)
The only ways to import this are now:
import isPromise from 'is-promise';
or
const isPromise = require('is-promise');
If you were requiring things like the
package.json
file within the package, these are not part of the public API, and will no longer be accessible. -
is-promise now uses "default" exports in ES Modules environments (#30)
If you were using ES6 style imports via
import * as isPromise from 'is-promise';
you will need to update this to
import isPromise from 'is-promise';
If you were using CommonJS style
require
, no change is needed. -
This package now comes bundled with TypeScript definitions (#31)
This means you may get new errors that you didn't see before if you are using TypeScript. If you are not using TypeScript, this change will not impact you.
2.2.2
2.2.1
Attempted to fix ESM, but this is still broken for people who import the package.json file.
2.2.0
- Adds TypeScript definition
- Adds support for ES Module style default import
This version of is-promse is broken. Please use 2.2.2