-
Notifications
You must be signed in to change notification settings - Fork 3k
fix(typings): Use overloading instead of union type for typings filter, find, first, last. #2164
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
Conversation
You can see the diff |
How do you think about this? |
That was my thought for the solution as well. I have one idea... I need to validate first, I'll check that right now. |
Nope, that didn't work sadly. We can solve the guard case, or we can solve the much more common case. I would argue that it makes more sense to fix the common case. LGTM 👍 |
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.
remove the tslint:disable comments, and actually use the variables with something like expect()
, even if it's obvious like const x = 1; expect(x).to.equal(1)
}); | ||
|
||
it('should not be compile error', () => { | ||
// tslint:disable no-unused-variable |
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.
It's possible that a later version of TypeScript compiler might completely remove code related to unused variables as an optimization. I'm completely speculating, but it might be worth using expect()
to set some obvious assertions around the variables you're not using, and remove these tslint:disable
comments.
Oops - sorry, guys! I only found out about this today, but I put together what I hope is a fix for this that'll let us keep the new support without breaking the previous behavior. Please take a peek at #2170 before fully reverting it with this PR. I seem to have covered the concerns in #2163, but maybe there's something else that I missed. |
…r, find, first, last. Abstract ------------ - This fixes ReactiveX#2163 by reverts commit 922d04e. - So this reverts ReactiveX#2119 sadly. Drawback --------- - We would need specify type parameters to their method explicitly if we'd like to narrow the type via `predicate` as type guarde function. - However, I don't think this is a serious problem because we can avoid this drawback with specifying actual types only. - And this changes makes our typings more similar to [TypeScript's Array methods](https://github.com/Microsoft/TypeScript/blob/master/lib/lib.es5.d.ts#L1086-L1097).
739593f
to
26e4f0d
Compare
|
OK. I agree to close this ;-) |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Drawback
predicate
as type guarde function in some cases.Related issue (if exists)