Skip to content

Commit 766b5a7

Browse files
david-driscollbenlesh
authored andcommitted
feat(typescript): updated to typescript 2.4.0 (rc) (#2684)
Fixed code that was failing due to compiler upgrade Several methods are now using default generic arguments, which were introduced in ts2.3
1 parent 12bc7fe commit 766b5a7

File tree

6 files changed

+33
-30
lines changed

6 files changed

+33
-30
lines changed

package.json

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,10 @@
138138
{
139139
"name": "Andre Staltz",
140140
"email": "[email protected]"
141+
},
142+
{
143+
"name": "David Driscoll",
144+
"email": "[email protected]"
141145
}
142146
],
143147
"license": "Apache-2.0",
@@ -172,32 +176,32 @@
172176
"gzip-size": "^3.0.0",
173177
"http-server": "^0.9.0",
174178
"husky": "^0.13.3",
175-
"lint-staged": "3.2.5",
176-
"lodash": "^4.15.0",
179+
"lint-staged": "^4.0.0",
180+
"lodash": "^4.17.4",
177181
"madge": "^1.4.3",
178182
"markdown-doctest": "^0.9.1",
179183
"minimist": "^1.2.0",
180184
"mkdirp": "^0.5.1",
181-
"mocha": "^3.0.2",
185+
"mocha": "^3.4.2",
182186
"mocha-in-sauce": "0.0.1",
183187
"npm-run-all": "^4.0.2",
184188
"npm-scripts-info": "^0.3.4",
185-
"nyc": "^10.2.0",
189+
"nyc": "^11.0.2",
186190
"opn-cli": "^3.1.0",
187191
"platform": "^1.3.1",
188192
"promise": "^7.1.1",
189-
"protractor": "^3.1.1",
193+
"protractor": "^5.1.2",
190194
"rollup": "0.36.3",
191195
"rollup-plugin-inject": "^2.0.0",
192196
"rollup-plugin-node-resolve": "^2.0.0",
193197
"rx": "latest",
194198
"shx": "^0.2.2",
195-
"sinon": "^2.1.0",
196-
"sinon-chai": "^2.9.0",
199+
"sinon": "^2.3.5",
200+
"sinon-chai": "^2.11.0",
197201
"source-map-support": "^0.4.0",
198202
"tslib": "^1.7.1",
199203
"tslint": "^5.4.3",
200-
"typescript": "~2.3.0",
204+
"typescript": "^2.4.0",
201205
"validate-commit-msg": "^2.3.1",
202206
"watch": "^1.0.1",
203207
"webpack": "^1.13.1",

spec/observables/dom/ajax-spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -950,7 +950,7 @@ class MockXMLHttpRequest {
950950

951951
private previousRequest: MockXMLHttpRequest;
952952

953-
protected responseType: string = '';
953+
protected responseType: XMLHttpRequestResponseType = '';
954954
private eventHandlers: Array<any> = [];
955955
private readyState: number = 0;
956956

src/Observable.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ export class Observable<T> implements Subscribable<T> {
6464
* @param {Operator} operator the operator defining the operation to take on the observable
6565
* @return {Observable} a new observable with the Operator applied
6666
*/
67-
lift<R>(operator: Operator<T, R>): Observable<R> {
67+
lift<R = T>(operator: Operator<T, R>): Observable<R> {
6868
const observable = new Observable<R>();
6969
observable.source = this;
7070
observable.operator = operator;

src/operator/catch.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ import { subscribeToResult } from '../util/subscribeToResult';
1414
*
1515
* Observable.of(1, 2, 3, 4, 5)
1616
* .map(n => {
17-
* if (n == 4) {
18-
* throw 'four!';
17+
* if (n == 4) {
18+
* throw 'four!';
1919
* }
20-
* return n;
20+
* return n;
2121
* })
2222
* .catch(err => Observable.of('I', 'II', 'III', 'IV', 'V'))
2323
* .subscribe(x => console.log(x));
@@ -27,10 +27,10 @@ import { subscribeToResult } from '../util/subscribeToResult';
2727
*
2828
* Observable.of(1, 2, 3, 4, 5)
2929
* .map(n => {
30-
* if (n === 4) {
31-
* throw 'four!';
30+
* if (n === 4) {
31+
* throw 'four!';
3232
* }
33-
* return n;
33+
* return n;
3434
* })
3535
* .catch((err, caught) => caught)
3636
* .take(30)
@@ -64,16 +64,16 @@ import { subscribeToResult } from '../util/subscribeToResult';
6464
* @name catch
6565
* @owner Observable
6666
*/
67-
export function _catch<T, R>(this: Observable<T>, selector: (err: any, caught: Observable<T>) => ObservableInput<R>): Observable<T | R> {
67+
export function _catch<T, R = T>(this: Observable<T>, selector: (err: any, caught: Observable<R>) => ObservableInput<R>): Observable<R> {
6868
const operator = new CatchOperator(selector);
6969
const caught = this.lift(operator);
7070
return (operator.caught = caught);
7171
}
7272

73-
class CatchOperator<T, R> implements Operator<T, T | R> {
74-
caught: Observable<T>;
73+
class CatchOperator<T, R = T> implements Operator<T, R> {
74+
caught: Observable<R>;
7575

76-
constructor(private selector: (err: any, caught: Observable<T>) => ObservableInput<T | R>) {
76+
constructor(private selector: (err: any, caught: Observable<R>) => ObservableInput<R>) {
7777
}
7878

7979
call(subscriber: Subscriber<R>, source: any): any {
@@ -86,10 +86,10 @@ class CatchOperator<T, R> implements Operator<T, T | R> {
8686
* @ignore
8787
* @extends {Ignored}
8888
*/
89-
class CatchSubscriber<T, R> extends OuterSubscriber<T, T | R> {
89+
class CatchSubscriber<T, R> extends OuterSubscriber<T, R> {
9090
constructor(destination: Subscriber<any>,
91-
private selector: (err: any, caught: Observable<T>) => ObservableInput<T | R>,
92-
private caught: Observable<T>) {
91+
private selector: (err: any, caught: Observable<R>) => ObservableInput<R>,
92+
private caught: Observable<R>) {
9393
super(destination);
9494
}
9595

src/operator/defaultIfEmpty.ts

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { Observable } from '../Observable';
33
import { Subscriber } from '../Subscriber';
44

55
/* tslint:disable:max-line-length */
6-
export function defaultIfEmpty<T>(this: Observable<T>, defaultValue?: T): Observable<T>;
7-
export function defaultIfEmpty<T, R>(this: Observable<T>, defaultValue?: R): Observable<T | R>;
6+
export function defaultIfEmpty<T, R = T>(this: Observable<T>, defaultValue?: R): Observable<R>;
87
/* tslint:enable:max-line-length */
98

109
/**
@@ -37,16 +36,16 @@ export function defaultIfEmpty<T, R>(this: Observable<T>, defaultValue?: R): Obs
3736
* @method defaultIfEmpty
3837
* @owner Observable
3938
*/
40-
export function defaultIfEmpty<T, R>(this: Observable<T>, defaultValue: R = null): Observable<T | R> {
39+
export function defaultIfEmpty<T, R = T>(this: Observable<T>, defaultValue: R = null): Observable<R> {
4140
return this.lift(new DefaultIfEmptyOperator(defaultValue));
4241
}
4342

44-
class DefaultIfEmptyOperator<T, R> implements Operator<T, T | R> {
43+
class DefaultIfEmptyOperator<T, R> implements Operator<T, R> {
4544

4645
constructor(private defaultValue: R) {
4746
}
4847

49-
call(subscriber: Subscriber<T | R>, source: any): any {
48+
call(subscriber: Subscriber<R>, source: any): any {
5049
return source.subscribe(new DefaultIfEmptySubscriber(subscriber, this.defaultValue));
5150
}
5251
}
@@ -59,7 +58,7 @@ class DefaultIfEmptyOperator<T, R> implements Operator<T, T | R> {
5958
class DefaultIfEmptySubscriber<T, R> extends Subscriber<T> {
6059
private isEmpty: boolean = true;
6160

62-
constructor(destination: Subscriber<T | R>, private defaultValue: R) {
61+
constructor(destination: Subscriber<R>, private defaultValue: R) {
6362
super(destination);
6463
}
6564

src/util/isPromise.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export function isPromise<T>(value: any | Promise<T>): value is Promise<T> {
1+
export function isPromise<T>(value: any | PromiseLike<T>): value is PromiseLike<T> {
22
return value && typeof (<any>value).subscribe !== 'function' && typeof (value as any).then === 'function';
33
}

0 commit comments

Comments
 (0)