Skip to content

Commit f27902d

Browse files
masaeedukwonoj
authored andcommitted
fix(typings): remove R from Operator.call, update operators accordingly
1 parent 603c9eb commit f27902d

File tree

15 files changed

+27
-28
lines changed

15 files changed

+27
-28
lines changed

src/Operator.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {Subscriber} from './Subscriber';
22

33
export class Operator<T, R> {
4-
call<R>(subscriber: Subscriber<R>): Subscriber<T> {
4+
call(subscriber: Subscriber<R>): Subscriber<T> {
55
return new Subscriber<T>(subscriber);
66
}
77
}

src/observable/dom/WebSocketSubject.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export class WebSocketSubject<T> extends Subject<T> {
6161

6262
lift<R>(operator: Operator<T, R>) {
6363
const sock: WebSocketSubject<T> = new WebSocketSubject(this, this.destination);
64-
sock.operator = operator;
64+
sock.operator = <any>operator;
6565
return sock;
6666
}
6767

src/operator/defaultIfEmpty.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,20 @@ export function defaultIfEmpty<T, R>(defaultValue: R = null): Observable<T | R>
1111
return this.lift(new DefaultIfEmptyOperator(defaultValue));
1212
}
1313

14-
class DefaultIfEmptyOperator<T, R> implements Operator<T, R> {
14+
class DefaultIfEmptyOperator<T, R> implements Operator<T, T | R> {
1515

1616
constructor(private defaultValue: R) {
1717
}
1818

19-
call(subscriber: Subscriber<T>): Subscriber<T> {
19+
call(subscriber: Subscriber<T | R>): Subscriber<T> {
2020
return new DefaultIfEmptySubscriber(subscriber, this.defaultValue);
2121
}
2222
}
2323

2424
class DefaultIfEmptySubscriber<T, R> extends Subscriber<T> {
2525
private isEmpty: boolean = true;
2626

27-
constructor(destination: Subscriber<T>, private defaultValue: R) {
27+
constructor(destination: Subscriber<T | R>, private defaultValue: R) {
2828
super(destination);
2929
}
3030

src/operator/distinct.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ import {subscribeToResult} from '../util/subscribeToResult';
1616
* @param {Observable} [flushes] optional Observable for flushing the internal HashSet of the operator.
1717
* @returns {Observable} an Observable that emits items from the source Observable with distinct values.
1818
*/
19-
export function distinct<T>(compare?: (x: T, y: T) => boolean, flushes?: Observable<any>) {
19+
export function distinct<T>(compare?: (x: T, y: T) => boolean, flushes?: Observable<any>): Observable<T> {
2020
return this.lift(new DistinctOperator(compare, flushes));
2121
}
2222

23-
class DistinctOperator<T, R> implements Operator<T, R> {
23+
class DistinctOperator<T> implements Operator<T, T> {
2424
constructor(private compare: (x: T, y: T) => boolean, private flushes: Observable<any>) {
2525
}
2626

src/operator/every.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function every<T>(predicate: (value: T, index: number, source: Observable
3939
return source.lift(new EveryOperator(predicate, thisArg, source));
4040
}
4141

42-
class EveryOperator<T, R> implements Operator<T, R> {
42+
class EveryOperator<T, R> implements Operator<T, boolean> {
4343
constructor(private predicate: (value: T, index: number, source: Observable<T>) => boolean,
4444
private thisArg?: any,
4545
private source?: Observable<T>) {

src/operator/groupBy.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export interface RefCountSubscription {
3131
attemptedToUnsubscribe: boolean;
3232
}
3333

34-
class GroupByOperator<T, K, R> extends Operator<T, R> {
34+
class GroupByOperator<T, K, R> extends Operator<T, GroupedObservable<K, R>> {
3535
constructor(public source: Observable<T>,
3636
private keySelector: (value: T) => K,
3737
private elementSelector?: (value: T) => R,

src/operator/inspect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ export function inspect<T>(durationSelector: (value: T) => Observable<any> | Pro
1212
return this.lift(new InspectOperator(durationSelector));
1313
}
1414

15-
class InspectOperator<T, R> implements Operator<T, R> {
15+
class InspectOperator<T> implements Operator<T, T> {
1616
constructor(private durationSelector: (value: T) => Observable<any> | Promise<any>) {
1717
}
1818

src/operator/inspectTime.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export function inspectTime<T>(delay: number, scheduler: Scheduler = asap): Obse
99
return this.lift(new InspectTimeOperator(delay, scheduler));
1010
}
1111

12-
class InspectTimeOperator<T, R> implements Operator<T, R> {
12+
class InspectTimeOperator<T> implements Operator<T, T> {
1313
constructor(private delay: number, private scheduler: Scheduler) {
1414
}
1515

src/operator/isEmpty.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ export function isEmpty(): Observable<boolean> {
1313
return this.lift(new IsEmptyOperator());
1414
}
1515

16-
class IsEmptyOperator<T> implements Operator<boolean, boolean> {
17-
call (observer: Subscriber<T>): Subscriber<boolean> {
16+
class IsEmptyOperator implements Operator<any, boolean> {
17+
call (observer: Subscriber<boolean>): Subscriber<any> {
1818
return new IsEmptySubscriber(observer);
1919
}
2020
}
2121

22-
class IsEmptySubscriber extends Subscriber<boolean> {
23-
24-
constructor(destination: Subscriber<any>) {
22+
class IsEmptySubscriber extends Subscriber<any> {
23+
constructor(destination: Subscriber<boolean>) {
2524
super(destination);
2625
}
2726

src/operator/pairwise.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ import {Subscriber} from '../Subscriber';
1111
*
1212
* @returns {Observable<R>} an observable of pairs of values.
1313
*/
14-
export function pairwise<T>(): Observable<T> {
14+
export function pairwise<T>(): Observable<[T, T]> {
1515
return this.lift(new PairwiseOperator());
1616
}
1717

18-
class PairwiseOperator<T, R> implements Operator<T, R> {
19-
call(subscriber: Subscriber<T>): Subscriber<T> {
18+
class PairwiseOperator<T> implements Operator<T, [T, T]> {
19+
call(subscriber: Subscriber<[T, T]>): Subscriber<T> {
2020
return new PairwiseSubscriber(subscriber);
2121
}
2222
}
@@ -25,7 +25,7 @@ class PairwiseSubscriber<T> extends Subscriber<T> {
2525
private prev: T;
2626
private hasPrev: boolean = false;
2727

28-
constructor(destination: Subscriber<T>) {
28+
constructor(destination: Subscriber<[T, T]>) {
2929
super(destination);
3030
}
3131

0 commit comments

Comments
 (0)