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 17, 2015
1 parent a8941d7 commit 2d0af04
Show file tree
Hide file tree
Showing 143 changed files with 597 additions and 587 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 --suppressImplicitAnyIndexErrors",
"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 --suppressImplicitAnyIndexErrors",
"build_es6": "rm -rf dist/es6 && tsc src/Rx.ts src/Rx.KitchenSink.ts --outDir dist/es6 --sourceMap --target ES6 -d --diagnostics --pretty --noImplicitAny --suppressImplicitAnyIndexErrors",
"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?: <K, R>(keySelector: (value: T) => string,
elementSelector?: (value: T) => R,
durationSelector?: (group: GroupedObservable<R>) => Observable<any>) => Observable<GroupedObservable<R>>;
durationSelector?: (group: GroupedObservable<K, R>) => Observable<any>) => Observable<GroupedObservable<K, R>>;
ignoreElements?: () => Observable<T>;
last?: <R>(predicate?: (value: T, index: number) => boolean,
resultSelector?: (value: T, index: number) => R,
Expand Down
4 changes: 2 additions & 2 deletions 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 All @@ -68,4 +68,4 @@ export class Notification<T> {
static createComplete(): Notification<any> {
return this.completeNotification;
}
}
}
20 changes: 10 additions & 10 deletions src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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|Function|void) {
constructor(subscribe?: <R>(subscriber: Subscriber<R>) => Subscription | Function | void) {
if (subscribe) {
this._subscribe = subscribe;
}
Expand All @@ -45,7 +45,7 @@ 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|Function|void) => {
static create: Function = <T>(subscribe?: <R>(subscriber: Subscriber<R>) => Subscription | Function | void) => {
return new Observable<T>(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 Down Expand Up @@ -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,7 +141,7 @@ 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);
};
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: <K, R>(keySelector: (value: T) => string,
elementSelector?: (value: T) => R,
durationSelector?: (group: GroupedObservable<R>) => Observable<any>) => Observable<GroupedObservable<R>>;
durationSelector?: (group: GroupedObservable<K, R>) => Observable<any>) => Observable<GroupedObservable<K, R>>;
ignoreElements: () => Observable<T>;
inspect: (notifier: Observable<any>) => Observable<T>;
inspectTime: (delay: number, scheduler?: Scheduler) => Observable<T>;
Expand Down Expand Up @@ -278,4 +278,4 @@ export class Observable<T> implements CoreOperators<T> {
withLatestFrom: <R>(...observables: Array<Observable<any> | ((...values: Array<any>) => R)>) => Observable<R>;
zip: <R>(...observables: Array<Observable<any> | ((...values: Array<any>) => R)>) => Observable<R>;
zipAll: <R>(project?: (...values: Array<any>) => R) => Observable<R>;
}
}
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);
}
2 changes: 1 addition & 1 deletion src/Scheduler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {Action} from './scheduler/Action';

export interface Scheduler {
now(): number;
schedule<T>(work: (state?: any) => Subscription|void, delay?: number, state?: any): Subscription;
schedule<T>(work: (state?: any) => Subscription | void, delay?: number, state?: any): Subscription;
flush(): void;
actions: Action[];
scheduled: boolean;
Expand Down
8 changes: 4 additions & 4 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) {
subscriptionAdd.call(this, subscription);
}

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

Expand Down
6 changes: 3 additions & 3 deletions src/Subscription.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {noop} from './util/noop';

export class Subscription {
public static EMPTY: Subscription = (function(empty){
public static EMPTY: Subscription = (function(empty: any){
empty.isUnsubscribed = true;
return empty;
}(new Subscription()));
Expand Down Expand Up @@ -47,7 +47,7 @@ export class Subscription {
}
}

add(subscription: Subscription|Function|void): void {
add(subscription: Subscription | Function | void): void {
// return early if:
// 1. the subscription is null
// 2. we're attempting to add our this
Expand Down Expand Up @@ -99,4 +99,4 @@ export class Subscription {
}
}
}
}
}
2 changes: 1 addition & 1 deletion 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;
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;
10 changes: 5 additions & 5 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 @@ -41,8 +41,8 @@ export class ConnectableObservable<T> extends Observable<T> {
}
}

class ConnectableSubscription<T> extends Subscription {
constructor(protected connectable: ConnectableObservable<T>) {
class ConnectableSubscription extends Subscription {
constructor(protected connectable: ConnectableObservable<any>) {
super();
}

Expand All @@ -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
16 changes: 8 additions & 8 deletions src/observable/ScalarObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class ScalarObservable<T> extends Observable<T> {
return new ScalarObservable(value, scheduler);
}

static dispatch(state): void {
static dispatch(state: any): void {
const { done, value, subscriber } = state;

if (done) {
Expand Down Expand Up @@ -58,7 +58,7 @@ const proto = ScalarObservable.prototype;
proto.map = function <T, R>(project: (x: T, ix?: number) => R, thisArg?: any): Observable<R> {
let result = tryCatch(project).call(thisArg || this, this.value, 0);
if (result === errorObject) {
return new ErrorObservable(errorObject.e);
return new ErrorObservable<any>(errorObject.e);
} else {
return new ScalarObservable(project.call(thisArg || this, this.value, 0));
}
Expand All @@ -67,11 +67,11 @@ proto.map = function <T, R>(project: (x: T, ix?: number) => R, thisArg?: any): O
proto.filter = function <T>(select: (x: T, ix?: number) => boolean, thisArg?: any): Observable<T> {
let result = tryCatch(select).call(thisArg || this, this.value, 0);
if (result === errorObject) {
return new ErrorObservable(errorObject.e);
return new ErrorObservable<any>(errorObject.e);
} else if (result) {
return this;
} else {
return new EmptyObservable();
return new EmptyObservable<T>();
}
};

Expand All @@ -81,7 +81,7 @@ proto.reduce = function <T, R>(project: (acc: R, x: T) => R, seed?: R): Observab
}
let result = tryCatch(project)(seed, this.value);
if (result === errorObject) {
return new ErrorObservable(errorObject.e);
return new ErrorObservable<any>(errorObject.e);
} else {
return new ScalarObservable(result);
}
Expand All @@ -97,7 +97,7 @@ proto.count = function <T>(predicate?: (value: T, index: number, source: Observa
} else {
let result = tryCatch(predicate).call(this, this.value, 0, this);
if (result === errorObject) {
return new ErrorObservable(errorObject.e);
return new ErrorObservable<any>(errorObject.e);
} else {
return new ScalarObservable(result ? 1 : 0);
}
Expand All @@ -106,7 +106,7 @@ proto.count = function <T>(predicate?: (value: T, index: number, source: Observa

proto.skip = function <T>(count: number): Observable<T> {
if (count > 0) {
return new EmptyObservable();
return new EmptyObservable<T>();
}
return this;
};
Expand All @@ -115,5 +115,5 @@ proto.take = function <T>(count: number): Observable<T> {
if (count > 0) {
return this;
}
return new EmptyObservable();
return new EmptyObservable<T>();
};
Loading

0 comments on commit 2d0af04

Please sign in to comment.