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

Require a value when calling resolve function of a Promise #1583

Merged
merged 6 commits into from
Feb 16, 2021

Conversation

rchl
Copy link
Member

@rchl rchl commented Feb 14, 2021

Make the value passed to ResolveFunc non-optional. This allows to
skip some if-checks when handling resolved value in a fullfill
function.

This also aligns the behavior with a recent change in Typescript [1].

[1] https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#resolves-parameters-are-no-longer-optional-in-promises

Make the value passed to ResolveFunc non-optional. This allows to
skip some if-checks when handling receiving resolved value in a fullfill
function.

This also aligns the behavior with a recent change in Typescript [1].

[1] https://devblogs.microsoft.com/typescript/announcing-typescript-4-1/#resolves-parameters-are-no-longer-optional-in-promises
This reverts commit 725ec67.
@rchl
Copy link
Member Author

rchl commented Feb 14, 2021

Tricky one that mypy type error.

Even though the ResolveFunc requires an argument now, Promise.resolve() can still be called without argument according to TS types. So that creates a bit of a problem that I'm not sure how to fix with Python...

@rwols
Copy link
Member

rwols commented Feb 15, 2021

What's the plan here? Is this supposed to be merged before #1582 ?

@predragnikolic
Copy link
Member

If this gets merged I will remove one if statement in #1582 :)
This PR will probably be merged before #1582

@rchl rchl marked this pull request as draft February 16, 2021 07:58
@rchl
Copy link
Member Author

rchl commented Feb 16, 2021

I'd have to figure out how to fix the mypy issue first and so far I'm not sure.

@rchl rchl marked this pull request as ready for review February 16, 2021 08:58
@rchl
Copy link
Member Author

rchl commented Feb 16, 2021

I've made the argument to Promise.[resolve|on_main_thread|on_async_thread] non-optional. You decide if that's an OK solution. I don't hate it, I think being explicit is not a bad thing.

@rchl rchl merged commit ffef40e into st4000-exploration Feb 16, 2021
@rchl rchl deleted the fix/then-non-optional branch February 16, 2021 20:45
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.

3 participants