Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed type definition for Promise.finally #348

Merged
merged 2 commits into from
Jun 6, 2019

Conversation

Lucretiel
Copy link
Contributor

No description provided.

@Lucretiel
Copy link
Contributor Author

Per the docs:

A finally callback will not receive any argument, since there's no reliable means of determining if the promise was fulfilled or rejected. This use case is for precisely when you do not care about the rejection reason, or the fulfillment value, and so there's no need to provide it.

Unlike Promise.resolve(2).then(() => {}, () => {}) (which will be resolved with undefined), Promise.resolve(2).finally(() => {}) will be resolved with 2.

A throw (or returning a rejected promise) in the finally callback will reject the new promise with the rejection reason specified when calling throw().

@Lucretiel
Copy link
Contributor Author

Lucretiel commented May 13, 2019

Note: A more appropriate return type would be onFullfilled?: () => (void | Thenable<void>), but that's technically stricter than what the docs allow.

@stefanpenner stefanpenner merged commit a5abe50 into stefanpenner:master Jun 6, 2019
@stefanpenner
Copy link
Owner

thanks, LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants