-
Notifications
You must be signed in to change notification settings - Fork 3k
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
fix(toPromise): correct toPromise return type #5072
Conversation
LGTM. Do you think you could add some dtslint tests? They would need to go into this file: https://github.com/ReactiveX/rxjs/blob/master/spec-dtslint/Observable-spec.ts Also, whilst I agree with this change, there will need to be some discussion about it before it's merged. Although it fixes a problem, it is a breaking change. Whether or not it's okay for v7 or will have to wait until v8 will have to be determined. |
Thanks, done. As a note, I had to run
Understood. There's definitely other approaches with varying pros/cons, but I think this one is pretty straightforward so I hope it or a compatible variant of it ends up working out. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Yeah, that's happened to me, too. dtslint has been an ongoing source of frustration. It's a really useful tool and has helped improve the codebase, but some of the things it does are so annoying. |
I think the real fix for I know this has been discussed before, and I'm not saying we should break this for v7, but we should figure out if this is a change we want to make, given that it will make the change I'm suggesting even more breaking when it lands. I think we should discuss this at the next meeting. |
That also SGTM. I think that solution, though incompatible, basically serves the same purpose. |
Approved, but as a BREAKING CHANGE... (from Core Team meeting) |
As toPromise can resolve to undefined via the change in ReactiveX#5072.
As toPromise can resolve to undefined via the change in #5072.
* fix(toPromise): correct toPromise return type * fix(toPromise): add test for toPromise type BREAKING CHANGE: toPromise return type now returns `T | undefined` in TypeScript, which is correct, but may break builds.
As toPromise can resolve to undefined via the change in ReactiveX#5072.
* fix(toPromise): correct toPromise return type * fix(toPromise): add test for toPromise type BREAKING CHANGE: toPromise return type now returns `T | undefined` in TypeScript, which is correct, but may break builds.
As toPromise can resolve to undefined via the change in ReactiveX#5072.
Description:
As described in #4196, the typing of
toPromise
does not match reality as it may returnundefined
in the case that no value is ever emitted. We have hit this bug in practice and believe it would be very useful to fix the actual typing.(This does not implement the
default
argument as suggested in #4196 - while this seems like a reasonable addition, there are cases today where returning undefined is in fact desired, and it would be nice if the typing was correct for this case.)Related issue (if exists):
(cc @sadarby)