You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
export function distinctUntilChanged<T>(comparator?: (previous: T, current: T) => boolean): MonoTypeOperatorFunction<T>;
export function distinctUntilChanged<T, K>(
comparator: (previous: K, current: K) => boolean,
keySelector: (value: T) => K
): MonoTypeOperatorFunction<T>;
export function distinctUntilChanged<T, K>(
comparator?: (previous: K, current: K) => boolean,
keySelector: (value: T) => K = identity as (value: T) => K
): MonoTypeOperatorFunction<T>
the first overload is just the comparator,
the second one is the comparator and the key selector which means you can have two objects as T and property keys as K, which would be returned by the second argument which is the keySelector function.
The third overload is the implementation The implementation signature must also be compatible with the overload signatures
so in this case it is having a default value of identity which is a function returning the argument
export function identity<T>(x: T): T {
return x;
}
So in this case you don't need it actually
And also that's how typescript work.
`
Again, the signature used to write the function body can’t be “seen” from the outside.
The signature of the implementation is not visible from the outside. When writing an overloaded function, you should always have two or more signatures above the implementation of the function.
`
Myself i would have the K as keyof T so that non existent keys are not passed but that would mess up the overloading.
Describe the bug
Definition of the new overload
export function distinctUntilChanged<T, K>(
comparator?: (previous: K, current: K) => boolean,
keySelector: (value: T) => K = identity as (value: T) => K
): MonoTypeOperatorFunction
is not generated in the bunde (rxjs/dist/types/internal/operators/distinctUntilChanged.d.ts)
Expected behavior
Have it with the other ones:
Reproduction code
No response
Reproduction URL
No response
Version
7.8.1
Environment
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: