Skip to content

Commit

Permalink
chore(distinctUntilKeyChanged): nail down key's typing with keyof T
Browse files Browse the repository at this point in the history
  • Loading branch information
imcotton committed Aug 3, 2018
1 parent 7120642 commit 0a0c9f4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions compat/operator/distinctUntilKeyChanged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { Observable } from 'rxjs';
import { distinctUntilKeyChanged as higherOrder } from 'rxjs/operators';

/* tslint:disable:max-line-length */
export function distinctUntilKeyChanged<T>(this: Observable<T>, key: string): Observable<T>;
export function distinctUntilKeyChanged<T>(this: Observable<T>, key: string, compare: <K> (x: K, y: K) => boolean): Observable<T>;
export function distinctUntilKeyChanged<T>(this: Observable<T>, key: keyof T): Observable<T>;
export function distinctUntilKeyChanged<T>(this: Observable<T>, key: keyof T, compare: <K> (x: K, y: K) => boolean): Observable<T>;
/* tslint:enable:max-line-length */

/**
Expand Down Expand Up @@ -64,6 +64,6 @@ export function distinctUntilKeyChanged<T>(this: Observable<T>, key: string, com
* @method distinctUntilKeyChanged
* @owner Observable
*/
export function distinctUntilKeyChanged<T>(this: Observable<T>, key: string, compare?: <K> (x: K, y: K) => boolean): Observable<T> {
export function distinctUntilKeyChanged<T>(this: Observable<T>, key: keyof T, compare?: <K> (x: K, y: K) => boolean): Observable<T> {
return higherOrder<T>(key, compare)(this);
}
6 changes: 3 additions & 3 deletions src/internal/operators/distinctUntilKeyChanged.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { distinctUntilChanged } from './distinctUntilChanged';
import { MonoTypeOperatorFunction } from '../types';

/* tslint:disable:max-line-length */
export function distinctUntilKeyChanged<T>(key: string): MonoTypeOperatorFunction<T>;
export function distinctUntilKeyChanged<T>(key: string, compare: <K> (x: K, y: K) => boolean): MonoTypeOperatorFunction<T>;
export function distinctUntilKeyChanged<T>(key: keyof T): MonoTypeOperatorFunction<T>;
export function distinctUntilKeyChanged<T>(key: keyof T, compare: <K> (x: K, y: K) => boolean): MonoTypeOperatorFunction<T>;
/* tslint:enable:max-line-length */

/**
Expand Down Expand Up @@ -70,6 +70,6 @@ export function distinctUntilKeyChanged<T>(key: string, compare: <K> (x: K, y: K
* @method distinctUntilKeyChanged
* @owner Observable
*/
export function distinctUntilKeyChanged<T>(key: string, compare?: <K> (x: K, y: K) => boolean): MonoTypeOperatorFunction<T> {
export function distinctUntilKeyChanged<T>(key: keyof T, compare?: <K> (x: K, y: K) => boolean): MonoTypeOperatorFunction<T> {
return distinctUntilChanged((x: T, y: T) => compare ? compare(x[key], y[key]) : x[key] === y[key]);
}

0 comments on commit 0a0c9f4

Please sign in to comment.