-
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(pluck): fix pluck's catch-all signature for better type safety #5192
Conversation
Change pluck's catch-all signature that is causing troubles when the passed string is not a key in the argument object. Issue: #5188
Just happened to see that there is a line that was added 7 months ago that does virtually the same but with one core difference: if you use |
Correct the signtaure to be accepted by tests and to return unknown in general
Also, I've added a test case that checks type inference: it('should not infer type from the variable if key doesn\'t exist', () => {
const a: Observable<number> = of({ name: 'abc' }).pipe(pluck('xyz')); // $ExpectError
}); With the old implementation there's no error emitting and the |
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. Thanks.
This can't go into patch, because it will break people's builds if they're violating the new constraint. However, it's a good addition to master. |
…eactiveX#5192) * fix(pluck): fix pluck's catch-all signature for better type safety Change pluck's catch-all signature that is causing troubles when the passed string is not a key in the argument object. Issue: ReactiveX#5188 * fix(pluck): fix signature and tests Correct the signtaure to be accepted by tests and to return unknown in general * fix(pluck): add test case to check type inference
Description: Change pluck's catch-all signature that is causing troubles when the
passed string is not a key in the argument object.
Related issue (if exists): #5188