Skip to content

Commit 2f395da

Browse files
kwonojbenlesh
authored andcommitted
chore(TypeScript): Bump up typescript to latest (#3009)
* chore(package): bump up typescript to latest * chore(typings): remove deprecated typings * chore(spec): remove redundant reference * fix(error): custom error inherits via setPrototypeof BREAKING CHANGE: IE10 and lower will need to polyfill `Object.setPrototypeOf`
1 parent abf1627 commit 2f395da

14 files changed

+138
-48
lines changed

.dependency-cruiser.json

+107
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
{
2+
"forbidden": [
3+
{
4+
"name": "not-to-spec",
5+
"comment": "Don't allow dependencies from outside the spec folder to spec",
6+
"severity": "error",
7+
"from": {
8+
"pathNot": "^spec"
9+
},
10+
"to": {
11+
"path": "^spec"
12+
}
13+
},
14+
{
15+
"name": "not-to-spec",
16+
"comment": "Don't allow dependencies to (typescript/ javascript/ coffeescript) spec files",
17+
"severity": "error",
18+
"from": {},
19+
"to": {
20+
"path": "\\.spec\\.[js|ts|ls|coffee|litcoffee|coffee\\.md]$"
21+
}
22+
},
23+
{
24+
"name": "no-deprecated-core",
25+
"comment": "Warn about dependencies on deprecated core modules.",
26+
"severity": "warn",
27+
"from": {},
28+
"to": {
29+
"dependencyTypes": [
30+
"core"
31+
],
32+
"path": "^(punycode|domain)$"
33+
}
34+
},
35+
{
36+
"name": "no-deprecated-npm",
37+
"comment": "These npm modules are deprecated - find an alternative.",
38+
"severity": "warn",
39+
"from": {},
40+
"to": {
41+
"dependencyTypes": [
42+
"deprecated"
43+
]
44+
}
45+
},
46+
{
47+
"name": "not-to-dev-dep",
48+
"severity": "error",
49+
"comment": "Don't allow dependencies from src/app/lib to a development only package",
50+
"from": {
51+
"path": "^(src|app|lib)"
52+
},
53+
"to": {
54+
"dependencyTypes": [
55+
"npm-dev"
56+
]
57+
}
58+
},
59+
{
60+
"name": "no-non-package-json",
61+
"severity": "error",
62+
"comment": "Don't allow dependencies to packages not in package.json (except from within node_modules)",
63+
"from": {
64+
"pathNot": "^node_modules"
65+
},
66+
"to": {
67+
"dependencyTypes": [
68+
"undetermined",
69+
"npm-no-pkg",
70+
"npm-unknown"
71+
],
72+
"pathNot": "^electron"
73+
}
74+
},
75+
{
76+
"name": "peer-deps-used",
77+
"comment": "Error about the use of a peer dependency (peer dependencies are deprecated).",
78+
"severity": "error",
79+
"from": {},
80+
"to": {
81+
"dependencyTypes": [
82+
"npm-peer"
83+
]
84+
}
85+
},
86+
{
87+
"name": "no-duplicate-dep-types",
88+
"comment": "Warn if a dependency occurs in your package.json more than once (technically: has more than one dependency type)",
89+
"severity": "warn",
90+
"from": {},
91+
"to": {
92+
"moreThanOneDependencyType": true
93+
}
94+
},
95+
{
96+
"name": "no-circular",
97+
"severity": "error",
98+
"comment": "Error in case we have circular dependencies",
99+
"from": {
100+
"path": "^src"
101+
},
102+
"to": {
103+
"circular": true
104+
}
105+
}
106+
]
107+
}

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ before_install:
2626

2727
install:
2828
- npm install
29-
- if [ "$FULL_VALIDATE" == "true" ]; then npm run lint && npm run check_circular_dependencies; fi
29+
- if [ "$FULL_VALIDATE" == "true" ]; then npm run lint && npm run test:circular; fi
3030

3131
script:
3232
- if [ "$FULL_VALIDATE" == "true" ] && [ -n "DANGER_GITHUB_API_TOKEN" ]; then echo {} > ./.babelrc && npx danger; fi

package.json

+10-6
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
"exclude": [
1717
"node_modules",
1818
"dist",
19-
"typings",
2019
"*.d.ts",
2120
"src/**/MiscJSDoc.ts"
2221
],
@@ -52,7 +51,6 @@
5251
"build_perf": "Build CJS & Global build, run macro performance test",
5352
"build_test": "Build CJS package & test spec, execute mocha test runner",
5453
"build_docs": "Build ESM2015 & global package, create documentation using it",
55-
"check_circular_dependencies": "Check codebase has circular dependencies",
5654
"clean_dist_cjs": "Clean up existing CJS package output",
5755
"clean_dist_esm5": "Clean up existing ESM/ES5 package output",
5856
"clean_dist_esm2015": "Clean up existing ESM/ES2015 package output",
@@ -90,7 +88,6 @@
9088
"build_perf": "webdriver-manager update && npm-run-all build_cjs build_global perf",
9189
"build_docs": "npm-run-all build_global build_esm2015_for_docs build_cjs tests2png decision_tree_widget && esdoc -c esdoc.json && npm-run-all clean_dist_esm2015",
9290
"build_spec_browser": "webpack --config spec/support/webpack.mocha.config.js",
93-
"check_circular_dependencies": "madge ./dist/cjs --circular",
9491
"clean_dist": "shx rm -rf ./dist",
9592
"clean_dist_cjs": "shx rm -rf ./dist/cjs",
9693
"clean_dist_esm5": "shx rm -rf ./dist/esm5",
@@ -113,11 +110,12 @@
113110
"lint": "npm-run-all --parallel lint_*",
114111
"perf": "protractor protractor.conf.js",
115112
"perf_micro": "node ./perf/micro/index.js",
116-
"prepublish": "shx rm -rf ./typings && typings install && npm run build_all",
113+
"prepublish": "shx rm -rf ./typings && npm run build_all",
117114
"publish_docs": "./publish_docs.sh",
118115
"test_browser": "npm-run-all build_spec_browser && opn spec/support/mocha-browser-runner.html",
119116
"test": "cross-env TS_NODE_FAST=true mocha --compilers ts:ts-node/register --opts spec/support/coverage.opts \"spec/**/*-spec.ts\"",
120117
"test:cover": "cross-env TS_NODE_FAST=true nyc npm test",
118+
"test:circular": "dependency-cruise --validate .dependency-cruiser.json -x \"^node_modules\" src",
121119
"tests2png": "tsc && mkdirp tmp/docs/img && mkdirp spec-js/support && shx cp spec/support/*.opts spec-js/support/ && mocha --opts spec/support/tests2png.opts spec-js",
122120
"watch": "watch \"echo triggering build && npm run build_test && echo build completed\" src -d -u -w=15"
123121
},
@@ -171,6 +169,12 @@
171169
"homepage": "https://github.com/ReactiveX/RxJS",
172170
"devDependencies": {
173171
"@angular-devkit/build-optimizer": "0.0.24",
172+
"@types/chai": "^4.0.4",
173+
"@types/lodash": "^4.14.80",
174+
"@types/mocha": "^2.2.44",
175+
"@types/node": "^8.0.47",
176+
"@types/sinon": "^2.3.7",
177+
"@types/sinon-chai": "^2.7.29",
174178
"babel-polyfill": "^6.23.0",
175179
"benchmark": "^2.1.0",
176180
"benchpress": "2.0.0-beta.1",
@@ -182,6 +186,7 @@
182186
"cross-env": "^5.1.0",
183187
"cz-conventional-changelog": "^1.2.0",
184188
"danger": "^1.1.0",
189+
"dependency-cruiser": "^2.6.0",
185190
"doctoc": "^1.0.0",
186191
"escape-string-regexp": "^1.0.5 ",
187192
"esdoc": "^0.4.7",
@@ -222,8 +227,7 @@
222227
"ts-node": "^3.3.0",
223228
"tslib": "^1.5.0",
224229
"tslint": "^4.4.2",
225-
"typescript": "~2.0.6",
226-
"typings": "^2.0.0",
230+
"typescript": "latest",
227231
"validate-commit-msg": "^2.14.0",
228232
"watch": "^1.0.1",
229233
"webpack": "^1.13.1",

spec/helpers/marble-testing.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
///<reference path='../../typings/index.d.ts'/>
21
import { Observable } from '../../src/Observable';
32
import { SubscriptionLog } from '../../src/testing/SubscriptionLog';
43
import { ColdObservable } from '../../src/testing/ColdObservable';

spec/helpers/test-helper.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
///<reference path='../../typings/index.d.ts'/>
21
declare const global: any;
32

43
import * as Rx from '../../src/Rx';
54
import { ObservableInput } from '../../src/Observable';
65
import { root } from '../../src/util/root';
76
import { $$iterator } from '../../src/symbol/iterator';
87
import $$symbolObservable from 'symbol-observable';
9-
import { Observable } from '../../src/Observable';
108

119
export function lowerCaseO<T>(...args: Array<any>): Rx.Observable<T> {
1210

spec/helpers/testScheduler-ui.ts

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
///<reference path='../../typings/index.d.ts'/>
2-
31
import * as _ from 'lodash';
42
//import * as commonInterface from 'mocha/lib/interfaces/common';
53
//import * as escapeRe from 'escape-string-regexp';

spec/util/UnsubscriptionError-spec.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,7 @@ describe('UnsubscriptionError', () => {
1919
subscription.unsubscribe();
2020
} catch (err) {
2121
expect(err instanceof UnsubscriptionError).to.equal(true);
22-
expect(err.message).to.equal(`2 errors occurred during unsubscription:
23-
1) ${err1}
24-
2) ${err2}`);
22+
expect(err.errors).to.deep.equal([err1, err2]);
2523
expect(err.name).to.equal('UnsubscriptionError');
2624
}
2725
});

src/observable/dom/AjaxObservable.ts

+4
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,9 @@ export class AjaxError extends Error {
452452
this.status = xhr.status;
453453
this.responseType = xhr.responseType || request.responseType;
454454
this.response = parseXhrResponse(this.responseType, xhr);
455+
456+
this.name = 'AjaxError';
457+
(Object as any).setPrototypeOf(this, AjaxError.prototype);
455458
}
456459
}
457460

@@ -480,5 +483,6 @@ function parseXhrResponse(responseType: string, xhr: XMLHttpRequest) {
480483
export class AjaxTimeoutError extends AjaxError {
481484
constructor(xhr: XMLHttpRequest, request: AjaxRequest) {
482485
super('ajax timeout', xhr, request);
486+
(Object as any).setPrototypeOf(this, AjaxTimeoutError.prototype);
483487
}
484488
}

src/util/ArgumentOutOfRangeError.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
*/
1111
export class ArgumentOutOfRangeError extends Error {
1212
constructor() {
13-
const err: any = super('argument out of range');
14-
(<any> this).name = err.name = 'ArgumentOutOfRangeError';
15-
(<any> this).stack = err.stack;
16-
(<any> this).message = err.message;
13+
super('argument out of range');
14+
this.name = 'ArgumentOutOfRangeError';
15+
(Object as any).setPrototypeOf(this, ArgumentOutOfRangeError.prototype);
1716
}
1817
}

src/util/EmptyError.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@
1010
*/
1111
export class EmptyError extends Error {
1212
constructor() {
13-
const err: any = super('no elements in sequence');
14-
(<any> this).name = err.name = 'EmptyError';
15-
(<any> this).stack = err.stack;
16-
(<any> this).message = err.message;
13+
super('no elements in sequence');
14+
this.name = 'EmptyError';
15+
(Object as any).setPrototypeOf(this, EmptyError.prototype);
1716
}
1817
}

src/util/ObjectUnsubscribedError.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@
99
*/
1010
export class ObjectUnsubscribedError extends Error {
1111
constructor() {
12-
const err: any = super('object unsubscribed');
13-
(<any> this).name = err.name = 'ObjectUnsubscribedError';
14-
(<any> this).stack = err.stack;
15-
(<any> this).message = err.message;
12+
super('object unsubscribed');
13+
this.name = 'ObjectUnsubscribedError';
14+
(Object as any).setPrototypeOf(this, ObjectUnsubscribedError.prototype);
1615
}
1716
}

src/util/TimeoutError.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
*/
88
export class TimeoutError extends Error {
99
constructor() {
10-
const err: any = super('Timeout has occurred');
11-
(<any> this).name = err.name = 'TimeoutError';
12-
(<any> this).stack = err.stack;
13-
(<any> this).message = err.message;
10+
super('Timeout has occurred');
11+
12+
(Object as any).setPrototypeOf(this, TimeoutError.prototype);
1413
}
1514
}

src/util/UnsubscriptionError.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@
44
*/
55
export class UnsubscriptionError extends Error {
66
constructor(public errors: any[]) {
7-
super();
8-
const err: any = Error.call(this, errors ?
7+
super(errors ?
98
`${errors.length} errors occurred during unsubscription:
109
${errors.map((err, i) => `${i + 1}) ${err.toString()}`).join('\n ')}` : '');
11-
(<any> this).name = err.name = 'UnsubscriptionError';
12-
(<any> this).stack = err.stack;
13-
(<any> this).message = err.message;
10+
this.name = 'UnsubscriptionError';
11+
(Object as any).setPrototypeOf(this, UnsubscriptionError.prototype);
1412
}
1513
}

typings.json

-12
This file was deleted.

0 commit comments

Comments
 (0)