Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(typings): Enabled noImplictAny #1077

Merged
merged 1 commit into from
Jan 11, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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\" && node tools/make-umd-bundle.js && node tools/make-system-bundle.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
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
16 changes: 8 additions & 8 deletions src/Observable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,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 @@ -66,7 +66,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 @@ -77,8 +77,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 @@ -132,7 +132,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 @@ -145,7 +145,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 @@ -212,9 +212,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>;
last: <R>(predicate?: (value: T, index: number) => boolean,
resultSelector?: (value: T, index: number) => R,
Expand Down
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;
active: boolean;
actions: Action[];
Expand Down
4 changes: 2 additions & 2 deletions src/Subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {rxSubscriber} from './symbol/rxSubscriber';
export class Subject<T> extends Observable<T> implements Observer<T>, Subscription {

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

constructor(source?: Observable<T>, destination?: Observer<T>) {
Expand All @@ -32,7 +32,7 @@ export class Subject<T> extends Observable<T> implements Observer<T>, Subscripti
lift<T, R>(operator: Operator<T, R>): Observable<T> {
const subject = new Subject(this, this.destination || this);
subject.operator = operator;
return subject;
return <any>subject;
}

add(subscription: Subscription|Function|void): void {
Expand Down
4 changes: 2 additions & 2 deletions src/Subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {isObject} from './util/isObject';
import {isFunction} from './util/isFunction';

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 @@ -46,7 +46,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
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
11 changes: 6 additions & 5 deletions src/observable/IteratorObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {isFunction} from '../util/isFunction';
import {SymbolShim} from '../util/SymbolShim';
import {errorObject} from '../util/errorObject';
import {Subscription} from '../Subscription';
import {Subscriber} from '../Subscriber';

export class IteratorObservable<T> extends Observable<T> {
private iterator: any;
Expand All @@ -18,7 +19,7 @@ export class IteratorObservable<T> extends Observable<T> {
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 @@ -83,7 +84,7 @@ export class IteratorObservable<T> extends Observable<T> {
this.iterator = getIterator(iterator);
}

_subscribe(subscriber): Subscription | Function | void {
_subscribe(subscriber: Subscriber<T>): Subscription | Function | void {

let index = 0;
const { iterator, project, thisArg, scheduler } = this;
Expand Down Expand Up @@ -166,7 +167,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 @@ -184,11 +185,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
8 changes: 4 additions & 4 deletions src/observable/ScalarObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,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 @@ -72,7 +72,7 @@ proto.filter = function <T>(select: (x: T, ix?: number) => boolean, thisArg?: an
} else if (result) {
return this;
} else {
return new EmptyObservable();
return new EmptyObservable<T>();
}
};

Expand Down Expand Up @@ -107,7 +107,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 @@ -116,5 +116,5 @@ proto.take = function <T>(count: number): Observable<T> {
if (count > 0) {
return this;
}
return new EmptyObservable();
return new EmptyObservable<T>();
};
14 changes: 7 additions & 7 deletions src/observable/bindCallback.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@ export class BoundCallbackObservable<T> extends Observable<T> {
subject: AsyncSubject<T>;

static create<T>(callbackFunc: Function,
selector: Function = undefined,
scheduler?: Scheduler): Function {
return (...args): Observable<T> => {
return new BoundCallbackObservable(callbackFunc, selector, args, scheduler);
selector: Function | void = undefined,
scheduler?: Scheduler): (...args: any[]) => Observable<T> {
return (...args: any[]): Observable<T> => {
return new BoundCallbackObservable<T>(callbackFunc, <any>selector, args, scheduler);
};
}

constructor(private callbackFunc: Function,
private selector,
private selector: Function,
private args: any[],
public scheduler: Scheduler) {
super();
Expand All @@ -33,7 +33,7 @@ export class BoundCallbackObservable<T> extends Observable<T> {
if (!scheduler) {
if (!subject) {
subject = this.subject = new AsyncSubject<T>();
const handler = function handlerFn(...innerArgs) {
const handler = function handlerFn(...innerArgs: any[]) {
const source = (<any>handlerFn).source;
const { selector, subject } = source;
if (selector) {
Expand Down Expand Up @@ -73,7 +73,7 @@ function dispatch<T>(state: { source: BoundCallbackObservable<T>, subscriber: Su
if (!subject) {
subject = source.subject = new AsyncSubject<T>();

const handler = function handlerFn(...innerArgs) {
const handler = function handlerFn(...innerArgs: any[]) {
const source = (<any>handlerFn).source;
const { selector, subject } = source;
if (selector) {
Expand Down
5 changes: 3 additions & 2 deletions src/observable/empty.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import {Scheduler} from '../Scheduler';
import {Subscriber} from '../Subscriber';
import {Observable} from '../Observable';
import {Subscription} from '../Subscription';

export class EmptyObservable<T> extends Observable<T> {

static create<T>(scheduler?: Scheduler): Observable<T> {
return new EmptyObservable(scheduler);
return new EmptyObservable<T>(scheduler);
}

static dispatch({ subscriber }) {
Expand All @@ -16,7 +17,7 @@ export class EmptyObservable<T> extends Observable<T> {
super();
}

_subscribe(subscriber): Subscription | Function | void {
_subscribe(subscriber: Subscriber<T>): Subscription | Function | void {

const scheduler = this.scheduler;

Expand Down
15 changes: 7 additions & 8 deletions src/observable/forkJoin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ import {isArray} from '../util/isArray';

export class ForkJoinObservable<T> extends Observable<T> {
constructor(private sources: Array<Observable<any> | Promise<any>>,
private resultSelector?: (...values: Array<any>) => any) {
private resultSelector?: (...values: Array<any>) => T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does resultSelector always return T? what about cases like below snippet?

Rx.Observable.forkJoin(
  Rx.Observable.just(42),
  Rx.Observable.just(56),
  function (x, y) { return x.toString() + y.toString(); }
);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

T isn't used anywhere in the sources of the selector, to T is really just the result. In this case it would return a string based on the code snippet.

super();
}

static create(...sources: Array<Observable<any> |
static create<T>(...sources: Array<Observable<any> | Promise<any> |
Array<Observable<any>> |
Promise<any> |
((...values: Array<any>) => any)>): Observable<any> {
((...values: Array<any>) => any)>): Observable<T> {
if (sources === null || arguments.length === 0) {
return new EmptyObservable();
return new EmptyObservable<T>();
}

let resultSelector: (...values: Array<any>) => any = null;
Expand Down Expand Up @@ -49,7 +48,7 @@ export class ForkJoinObservable<T> extends Observable<T> {
}

class AllSubscriber<T> extends Subscriber<T> {
private _value: any = null;
private _value: T = null;

constructor(destination: Subscriber<any>,
private index: number,
Expand All @@ -60,7 +59,7 @@ class AllSubscriber<T> extends Subscriber<T> {
super(destination);
}

_next(value: any): void {
_next(value: T): void {
this._value = value;
}

Expand Down Expand Up @@ -95,7 +94,7 @@ function hasValue(x: any): boolean {
}

function emptyArray(len: number): any[] {
let arr = [];
let arr: any[] = [];
for (let i = 0; i < len; i++) {
arr.push(null);
}
Expand Down
4 changes: 2 additions & 2 deletions src/observable/from.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {Subscriber} from '../Subscriber';
import {ObserveOnSubscriber} from '../operator/observeOn-support';

export class FromObservable<T> extends Observable<T> {
constructor(private ish: any, private scheduler: Scheduler) {
constructor(private ish: Observable<T> | Promise<T> | Iterator<T> | ArrayLike<T>, private scheduler: Scheduler) {
super(null);
}

Expand All @@ -27,7 +27,7 @@ export class FromObservable<T> extends Observable<T> {
} else if (isPromise(ish)) {
return new PromiseObservable(ish, scheduler);
} else if (typeof ish[SymbolShim.iterator] === 'function') {
return new IteratorObservable(ish, null, null, scheduler);
return new IteratorObservable<T>(<any>ish, null, null, scheduler);
}
}

Expand Down
Loading