-
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
DistinctUntilChanged keyselector typing issue #5484
Comments
I mean it effects errors in the code, but the pop-up box gets it right. |
It's a TypeScript problem; there's nothing we can/should do about it. Like you say, it's because the inference goes from left to right. If the parameters are reversed, the types are inferred correctly. The solution/workaround is to provide an explicit type for at least one of the parameters in the first callback: (prevCar: string, nextCar) => {
return prevCar.toLowerCase() === nextCar.toLowerCase();
}, |
Related: #5679 (comment) |
I am not entirely sure for the reason behind that so I create this issue rather than fixing it.
Calling
distinctUntilChanged
with an anonymouskeyselector
function leads toK
being infered asunknown
.car
is actually properly inferred here but for some reason, the return type of that function needs to be specified explicitly.For reference this is the "problematic" function signature:
It seems like the type inference is processing from left to right and there
K
will be defaulted tounknown
in the compare function, but I am not really sure about this.The text was updated successfully, but these errors were encountered: