Skip to content

Commit

Permalink
fix(compilation): compile under typescript 2.4 (#2780)
Browse files Browse the repository at this point in the history
TypeScript 2.4 is more strict about assignability with generics,
and in some cases (when calling a generic function) it will infer
that the generic parameter is <{}> rather than the <T> that rxjs
typically wants.

Fix this by explicitly passing <T> in the cases where compilation
fails.
  • Loading branch information
evmar authored and benlesh committed Aug 3, 2017
1 parent b8a324f commit d2a32f9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/observable/FromObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export class FromObservable<T> extends Observable<T> {
return new FromObservable<T>(ish, scheduler);
} else if (isArray(ish)) {
return new ArrayObservable<T>(ish, scheduler);
} else if (isPromise(ish)) {
} else if (isPromise<T>(ish)) {
return new PromiseObservable<T>(ish, scheduler);
} else if (typeof ish[Symbol_iterator] === 'function' || typeof ish === 'string') {
return new IteratorObservable<T>(ish, scheduler);
Expand Down
2 changes: 1 addition & 1 deletion src/operator/catch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ import { subscribeToResult } from '../util/subscribeToResult';
*/
export function _catch<T, R>(this: Observable<T>, selector: (err: any, caught: Observable<T>) => ObservableInput<R>): Observable<T | R> {
const operator = new CatchOperator(selector);
const caught = this.lift(operator);
const caught = this.lift<T>(operator);
return (operator.caught = caught);
}

Expand Down
2 changes: 1 addition & 1 deletion src/operator/defaultIfEmpty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export function defaultIfEmpty<T, R>(this: Observable<T>, defaultValue?: R): Obs
* @owner Observable
*/
export function defaultIfEmpty<T, R>(this: Observable<T>, defaultValue: R = null): Observable<T | R> {
return this.lift(new DefaultIfEmptyOperator(defaultValue));
return this.lift<T>(new DefaultIfEmptyOperator(defaultValue));
}

class DefaultIfEmptyOperator<T, R> implements Operator<T, T | R> {
Expand Down

0 comments on commit d2a32f9

Please sign in to comment.