Skip to content

Commit

Permalink
chore(typings): Enabled noImplictAny and updated typings
Browse files Browse the repository at this point in the history
With this change compliation time and performance is improved
  • Loading branch information
david-driscoll committed Dec 13, 2015
1 parent 7f67b09 commit 4d9d33d
Show file tree
Hide file tree
Showing 154 changed files with 719 additions and 669 deletions.
4 changes: 2 additions & 2 deletions src/CoreOperators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ export interface CoreOperators<T> {
projectResult?: (x: T, y: any, ix: number, iy: number) => R,
concurrent?: number) => Observable<R>;
flatMapTo?: <R>(observable: Observable<any>, projectResult?: (x: T, y: any, ix: number, iy: number) => R, concurrent?: number) => Observable<R>;
groupBy?: <R>(keySelector: (value: T) => string,
groupBy?: <TKey, R>(keySelector: (value: T) => string,
elementSelector?: (value: T) => R,
durationSelector?: (group: GroupedObservable<R>) => Observable<any>) => Observable<GroupedObservable<R>>;
durationSelector?: (group: GroupedObservable<TKey, R>) => Observable<any>) => Observable<GroupedObservable<TKey, R>>;
ignoreElements?: () => Observable<T>;
last?: <R>(predicate?: (value: T, index: number) => boolean,
resultSelector?: (value: T, index: number) => R,
Expand Down
2 changes: 1 addition & 1 deletion src/Notification.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Notification<T> {
case 'E':
return Observable.throw(this.exception);
case 'C':
return Observable.empty();
return Observable.empty<T>();
}
}

Expand Down
28 changes: 14 additions & 14 deletions src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {rxSubscriber} from'./symbol/rxSubscriber';
export class Observable<T> implements CoreOperators<T> {
source: Observable<any>;
operator: Operator<any, T>;
_isScalar: boolean = false;
_isScalar = false;

/**
* @constructor
Expand All @@ -30,7 +30,7 @@ export class Observable<T> implements CoreOperators<T> {
* can be `next`ed, or an `error` method can be called to raise an error, or `complete` can be called to notify
* of a successful completion.
*/
constructor(subscribe?: <R>(subscriber: Subscriber<R>) => Subscription<T>|Function|void) {
constructor(subscribe?: <R>(subscriber: Subscriber<R> | Function) => Subscription<T>) {
if (subscribe) {
this._subscribe = subscribe;
}
Expand All @@ -45,8 +45,8 @@ export class Observable<T> implements CoreOperators<T> {
* @returns {Observable} a new cold observable
* @description creates a new cold Observable by calling the Observable constructor
*/
static create: Function = <T>(subscribe?: <R>(subscriber: Subscriber<R>) => Subscription<T>|Function|void) => {
return new Observable<T>(subscribe);
static create: Function = <T>(subscribe?: <R>(subscriber: Subscriber<R> | Function) => Subscription<T>) => {
return new Observable(subscribe);
};

/**
Expand All @@ -56,8 +56,8 @@ export class Observable<T> implements CoreOperators<T> {
* @description creates a new Observable, with this Observable as the source, and the passed
* operator defined as the new observable's operator.
*/
lift<T, R>(operator: Operator<T, R>): Observable<T> {
const observable = new Observable();
lift<T, R>(operator: Operator<T, R>): Observable<R> {
const observable = new Observable<R>();
observable.source = this;
observable.operator = operator;
return observable;
Expand Down Expand Up @@ -98,7 +98,7 @@ export class Observable<T> implements CoreOperators<T> {
subscriber = new Subscriber(<Observer<T>> observerOrNext);
}
} else {
const next = <((x?) => void)> observerOrNext;
const next = <((x?: any) => void)> observerOrNext;
subscriber = Subscriber.create(next, error, complete);
}

Expand All @@ -115,7 +115,7 @@ export class Observable<T> implements CoreOperators<T> {
* @returns {Promise} a promise that either resolves on observable completion or
* rejects with the handled error
*/
forEach(next: (value: T) => void, thisArg: any, PromiseCtor?: PromiseConstructor): Promise<void> {
forEach(next: (value: T) => void, thisArg: any, PromiseCtor?: PromiseConstructor): Promise<any> {
if (!PromiseCtor) {
if (root.Rx && root.Rx.config && root.Rx.config.Promise) {
PromiseCtor = root.Rx.config.Promise;
Expand All @@ -128,7 +128,7 @@ export class Observable<T> implements CoreOperators<T> {
throw new Error('no Promise impl found');
}

let nextHandler;
let nextHandler: any;

if (thisArg) {
nextHandler = function nextHandlerFn(value: any): void {
Expand All @@ -141,17 +141,17 @@ export class Observable<T> implements CoreOperators<T> {
nextHandler = next;
}

const promiseCallback = function promiseCallbackFn(resolve, reject) {
const promiseCallback = function promiseCallbackFn(resolve: Function, reject: Function) {
const { source, nextHandler } = <any>promiseCallbackFn;
source.subscribe(nextHandler, reject, resolve);
};
(<any>promiseCallback).source = this;
(<any>promiseCallback).nextHandler = nextHandler;

return new PromiseCtor<void>(promiseCallback);
return new PromiseCtor(promiseCallback);
}

_subscribe(subscriber: Subscriber<any>): Subscription<T> | Function | void {
_subscribe(subscriber: Subscriber<any>): Subscription<T> | Function | any {
return this.source._subscribe(this.operator.call(subscriber));
}

Expand Down Expand Up @@ -216,9 +216,9 @@ export class Observable<T> implements CoreOperators<T> {
projectResult?: (x: T, y: any, ix: number, iy: number) => R,
concurrent?: number) => Observable<R>;
flatMapTo: <R>(observable: Observable<any>, projectResult?: (x: T, y: any, ix: number, iy: number) => R, concurrent?: number) => Observable<R>;
groupBy: <R>(keySelector: (value: T) => string,
groupBy: <TKey, R>(keySelector: (value: T) => string,
elementSelector?: (value: T) => R,
durationSelector?: (group: GroupedObservable<R>) => Observable<any>) => Observable<GroupedObservable<R>>;
durationSelector?: (group: GroupedObservable<TKey, R>) => Observable<any>) => Observable<GroupedObservable<TKey, R>>;
ignoreElements: () => Observable<T>;
last: <R>(predicate?: (value: T, index: number) => boolean,
resultSelector?: (value: T, index: number) => R,
Expand Down
2 changes: 1 addition & 1 deletion src/Operator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ export interface Operator<T, R> {
}

export function defaultCallFn<T, R>(observer: Observer<R>): Observer<T> {
return new Subscriber<T>(observer);
return new Subscriber(observer);
}
4 changes: 2 additions & 2 deletions src/Scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import {Action} from './scheduler/Action';

export interface Scheduler {
now(): number;
schedule<T>(work: (state?: any) => Subscription<T>|void, delay?: number, state?: any): Subscription<T>;
schedule<T>(work: (state?: any) => Subscription<T> | void, delay?: number, state?: any): Subscription<T>;
flush(): void;
actions: Action[];
scheduled: boolean;
active: boolean;
}
}
10 changes: 5 additions & 5 deletions src/Subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class Subject<T> extends Observable<T> implements Observer<T>, Subscripti
}

static create<T>(source: Observable<T>, destination: Observer<T>): Subject<T> {
return new BidirectionalSubject(source, destination);
return new BidirectionalSubject<T>(source, destination);
}

protected destination: Observer<T>;
Expand All @@ -40,7 +40,7 @@ export class Subject<T> extends Observable<T> implements Observer<T>, Subscripti
completeSignal: boolean = false;

lift<T, R>(operator: Operator<T, R>): Observable<T> {
const subject = new BidirectionalSubject(this, this.destination || this);
const subject = new BidirectionalSubject<T>(this, this.destination || this);
subject.operator = operator;
return subject;
}
Expand All @@ -63,11 +63,11 @@ export class Subject<T> extends Observable<T> implements Observer<T>, Subscripti
return new SubjectSubscription(this, subscriber);
}

add(subscription?) {
add(subscription?: Subscription<T>) {
subscriptionAdd.call(this, subscription);
}

remove(subscription?) {
remove(subscription?: Subscription<T>) {
subscriptionRemove.call(this, subscription);
}

Expand Down Expand Up @@ -199,4 +199,4 @@ class BidirectionalSubject<T> extends Subject<T> {
_complete(): void {
_subscriberComplete.call(this);
}
}
}
6 changes: 3 additions & 3 deletions src/Subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Subscriber<T> extends Subscription<T> implements Observer<T> {
static create<T>(next?: (x?: T) => void,
error?: (e?: any) => void,
complete?: () => void): Subscriber<T> {
const subscriber = new Subscriber<T>();
const subscriber = new Subscriber();
subscriber._next = (typeof next === 'function') && tryOrOnError(next) || noop;
subscriber._error = (typeof error === 'function') && error || throwError;
subscriber._complete = (typeof complete === 'function') && complete || noop;
Expand All @@ -58,7 +58,7 @@ export class Subscriber<T> extends Subscription<T> implements Observer<T> {
}
}

add(sub: Subscription<T> | Function | void): void {
add(sub: Subscription<T> | Function): void {
// route add to the shared Subscription if it exists
const _subscription = this._subscription;
if (_subscription) {
Expand Down Expand Up @@ -127,4 +127,4 @@ export class Subscriber<T> extends Subscription<T> implements Observer<T> {
this.unsubscribe();
}
}
}
}
8 changes: 4 additions & 4 deletions src/Subscription.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {noop} from './util/noop';

export class Subscription<T> {
public static EMPTY: Subscription<void> = (function(empty){
public static EMPTY: Subscription<void> = (function(empty: any){
empty.isUnsubscribed = true;
return empty;
}(new Subscription<void>()));
}(new Subscription()));

isUnsubscribed: boolean = false;

Expand Down Expand Up @@ -47,7 +47,7 @@ export class Subscription<T> {
}
}

add(subscription: Subscription<T>|Function|void): void {
add(subscription: Subscription<T> | Function): void {
// return early if:
// 1. the subscription is null
// 2. we're attempting to add our this
Expand All @@ -62,7 +62,7 @@ export class Subscription<T> {

switch (typeof subscription) {
case 'function':
sub = new Subscription<void>(<(() => void) > subscription);
sub = new Subscription(<(() => void) > subscription);
case 'object':
if (sub.isUnsubscribed || typeof sub.unsubscribe !== 'function') {
break;
Expand Down
4 changes: 2 additions & 2 deletions src/add/operator/exhaust.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Observable} from '../../Observable';
import {exhaust} from '../../operator/exhaust';
Observable.prototype.exhaust = exhaust;
(Observable.prototype as any).exhaust = exhaust;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/exhaustMap.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Observable} from '../../Observable';
import {exhaustMap} from '../../operator/exhaustMap';
Observable.prototype.exhaustMap = exhaustMap;
(Observable.prototype as any).exhaustMap = exhaustMap;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/extended/distinctUntilKeyChanged.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Observable} from '../../../Observable';
import {distinctUntilKeyChanged} from '../../../operator/extended/distinctUntilKeyChanged';
import {KitchenSinkOperators} from '../../../Rx.KitchenSink';
const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);
const observableProto = (<KitchenSinkOperators<any>><any>Observable.prototype);
observableProto.distinctUntilKeyChanged = distinctUntilKeyChanged;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/extended/elementAt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Observable} from '../../../Observable';
import {elementAt} from '../../../operator/extended/elementAt';
import {KitchenSinkOperators} from '../../../Rx.KitchenSink';
const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);
const observableProto = (<KitchenSinkOperators<any>><any>Observable.prototype);
observableProto.elementAt = elementAt;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/extended/find.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Observable} from '../../../Observable';
import {find} from '../../../operator/extended/find';
import {KitchenSinkOperators} from '../../../Rx.KitchenSink';
const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);
const observableProto = (<KitchenSinkOperators<any>><any>Observable.prototype);
observableProto.find = find;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/extended/findIndex.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Observable} from '../../../Observable';
import {findIndex} from '../../../operator/extended/findIndex';
import {KitchenSinkOperators} from '../../../Rx.KitchenSink';
const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);
const observableProto = (<KitchenSinkOperators<any>><any>Observable.prototype);
observableProto.findIndex = findIndex;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/extended/isEmpty.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Observable} from '../../../Observable';
import {isEmpty} from '../../../operator/extended/isEmpty';
import {KitchenSinkOperators} from '../../../Rx.KitchenSink';
const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);
const observableProto = (<KitchenSinkOperators<any>><any>Observable.prototype);
observableProto.isEmpty = isEmpty;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/extended/max.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Observable} from '../../../Observable';
import {max} from '../../../operator/extended/max';
import {KitchenSinkOperators} from '../../../Rx.KitchenSink';
const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);
const observableProto = (<KitchenSinkOperators<any>><any>Observable.prototype);
observableProto.max = max;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/extended/mergeScan.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Observable} from '../../../Observable';
import {mergeScan} from '../../../operator/extended/mergeScan';
import {KitchenSinkOperators} from '../../../Rx.KitchenSink';
const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);
const observableProto = (<KitchenSinkOperators<any>><any>Observable.prototype);
observableProto.mergeScan = mergeScan;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/extended/min.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Observable} from '../../../Observable';
import {min} from '../../../operator/extended/min';
import {KitchenSinkOperators} from '../../../Rx.KitchenSink';
const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);
const observableProto = (<KitchenSinkOperators<any>><any>Observable.prototype);
observableProto.min = min;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/extended/timeInterval.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {Observable} from '../../../Observable';
import {timeInterval} from '../../../operator/extended/timeInterval';
import {KitchenSinkOperators} from '../../../Rx.KitchenSink';
const observableProto = (<KitchenSinkOperators<any>>Observable.prototype);
const observableProto = (<KitchenSinkOperators<any>><any>Observable.prototype);
observableProto.timeInterval = timeInterval;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/zip-static.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Observable} from '../../Observable';
import {zip} from '../../operator/zip-static';
Observable.zip = zip;
Observable.zip = <any>zip;

export var _void: void;
export var _void: void;
4 changes: 2 additions & 2 deletions src/add/operator/zip.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Observable} from '../../Observable';
import {zipProto} from '../../operator/zip';
Observable.prototype.zip = zipProto;
import {zip} from '../../operator/zip';
Observable.prototype.zip = zip;

export var _void: void;
6 changes: 3 additions & 3 deletions src/observable/ConnectableObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ConnectableObservable<T> extends Observable<T> {
super();
}

_subscribe(subscriber) {
_subscribe(subscriber: Subscriber<T>) {
return this._getSubject().subscribe(subscriber);
}

Expand Down Expand Up @@ -62,9 +62,9 @@ class RefCountObservable<T> extends Observable<T> {
super();
}

_subscribe(subscriber) {
_subscribe(subscriber: Subscriber<T>) {
const connectable = this.connectable;
const refCountSubscriber = new RefCountSubscriber(subscriber, this);
const refCountSubscriber: RefCountSubscriber<T> = new RefCountSubscriber(subscriber, this);
const subscription = connectable.subscribe(refCountSubscriber);
if (!subscription.isUnsubscribed && ++this.refCount === 1) {
refCountSubscriber.connection = this.connection = connectable.connect();
Expand Down
Loading

0 comments on commit 4d9d33d

Please sign in to comment.