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
{{ message }}
Repository navigation
distintUntilChanged: new overload missing in bundle #7475
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.
Activity
conblem commentedon Jun 26, 2024
I am facing the same problem
al-mart commentedon Aug 1, 2024
If you analyze the source you will see
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 signaturesso in this case it is having a default value of identity which is a function returning the argument
So in this case you don't need it actually
And also that's how typescript work.
Official typescript
`
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.