Skip to content

Commit

Permalink
chore(typings): enabled noImplictAny
Browse files Browse the repository at this point in the history
  • Loading branch information
david-driscoll committed Dec 15, 2015
1 parent 6303558 commit 87e642e
Show file tree
Hide file tree
Showing 146 changed files with 645 additions and 637 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
},
"scripts": {
"build_all": "npm run build_es6 && npm run build_amd && npm run build_cjs && npm run build_global && npm run generate_packages",
"build_amd": "rm -rf dist/amd && tsc typings/es6-shim/es6-shim.d.ts src/Rx.ts -m amd --outDir dist/amd --sourcemap --target ES5 --diagnostics --pretty",
"build_cjs": "rm -rf dist/cjs && tsc typings/es6-shim/es6-shim.d.ts src/Rx.ts src/Rx.KitchenSink.ts -m commonjs --outDir dist/cjs --sourcemap --target ES5 -d --diagnostics --pretty",
"build_es6": "rm -rf dist/es6 && tsc src/Rx.ts src/Rx.KitchenSink.ts --outDir dist/es6 --sourceMap --target ES6 -d --diagnostics --pretty",
"build_amd": "rm -rf dist/amd && tsc typings/es6-shim/es6-shim.d.ts src/Rx.ts -m amd --outDir dist/amd --sourcemap --target ES5 --diagnostics --pretty --noImplicitAny",
"build_cjs": "rm -rf dist/cjs && tsc typings/es6-shim/es6-shim.d.ts src/Rx.ts src/Rx.KitchenSink.ts -m commonjs --outDir dist/cjs --sourcemap --target ES5 -d --diagnostics --pretty --noImplicitAny",
"build_es6": "rm -rf dist/es6 && tsc src/Rx.ts src/Rx.KitchenSink.ts --outDir dist/es6 --sourceMap --target ES6 -d --diagnostics --pretty --noImplicitAny",
"build_closure": "java -jar ./node_modules/google-closure-compiler/compiler.jar ./dist/global/Rx.umd.js --language_in ECMASCRIPT5 --create_source_map ./dist/global/Rx.umd.min.js.map --js_output_file ./dist/global/Rx.umd.min.js",
"build_global": "rm -rf dist/global && mkdir \"dist/global\" && browserify -s Rx dist/cjs/Rx.js --outfile dist/global/Rx.umd.js && npm run build_closure",
"build_perf": "npm run build_cjs && npm run build_global && webdriver-manager update && npm run perf",
Expand Down
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>;
inspect: (notifier: Observable<any>) => Observable<T>;
inspectTime: (delay: number, scheduler?: Scheduler) => Observable<T>;
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<any> | Function | void): void {
add(sub: Subscription<any> | 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<any>|Function|void): void {
add(subscription: Subscription<any> | 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
2 changes: 1 addition & 1 deletion src/add/operator/exhaust.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import {Observable} from '../../Observable';
import {exhaust} from '../../operator/exhaust';
Observable.prototype.exhaust = exhaust;

export var _void: void;
export var _void: void;
2 changes: 1 addition & 1 deletion src/add/operator/exhaustMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ import {Observable} from '../../Observable';
import {exhaustMap} from '../../operator/exhaustMap';
Observable.prototype.exhaustMap = exhaustMap;

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
15 changes: 8 additions & 7 deletions src/observable/IteratorObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@ import {root} from '../util/root';
import {SymbolShim} from '../util/SymbolShim';
import {tryCatch} from '../util/tryCatch';
import {errorObject} from '../util/errorObject';
import {Subscriber} from '../Subscriber';

export class IteratorObservable<T> extends Observable<T> {
private iterator: any;

static create<T>(iterator: any,
project?: (x?: any, i?: number) => T,
project?: (value: any, index: number) => T,
thisArg?: any,
scheduler?: Scheduler) {
return new IteratorObservable(iterator, project, thisArg, scheduler);
}

static dispatch(state) {
static dispatch(state: any) {

const { index, hasError, thisArg, project, iterator, subscriber } = state;

Expand Down Expand Up @@ -54,7 +55,7 @@ export class IteratorObservable<T> extends Observable<T> {
}

constructor(iterator: any,
private project?: (x?: any, i?: number) => T,
private project?: (value: any, index: number) => T,
private thisArg?: any,
private scheduler?: Scheduler) {
super();
Expand All @@ -67,7 +68,7 @@ export class IteratorObservable<T> extends Observable<T> {
this.iterator = getIterator(iterator);
}

_subscribe(subscriber) {
_subscribe(subscriber: Subscriber<T>) {

let index = 0;
const { iterator, project, thisArg, scheduler } = this;
Expand Down Expand Up @@ -150,7 +151,7 @@ function getIterator(obj: any) {

const maxSafeInteger = Math.pow(2, 53) - 1;

function toLength(o) {
function toLength(o: any) {
let len = +o.length;
if (isNaN(len)) {
return 0;
Expand All @@ -168,11 +169,11 @@ function toLength(o) {
return len;
}

function numberIsFinite(value) {
function numberIsFinite(value: any) {
return typeof value === 'number' && root.isFinite(value);
}

function sign(value) {
function sign(value: any) {
let valueAsNumber = +value;
if (valueAsNumber === 0) {
return valueAsNumber;
Expand Down
Loading

0 comments on commit 87e642e

Please sign in to comment.