Skip to content

Commit

Permalink
Merge pull request #4985 from benlesh/update-ts-3.5.3
Browse files Browse the repository at this point in the history
Update to TypeScript 3.5.3
  • Loading branch information
benlesh committed Sep 16, 2019
2 parents fc3d426 + 9e3bb85 commit 56cbd22
Show file tree
Hide file tree
Showing 46 changed files with 2,159 additions and 3,038 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Expand Up @@ -62,7 +62,7 @@ jobs:
<<: *defaults
steps:
- attach_workspace: *attach_options
- run: npm i --no-save typescript@3.*
- run: npm i --no-save typescript@3.5.*
- run: npm run build_cjs

workflows:
Expand Down
4,762 changes: 1,917 additions & 2,845 deletions package-lock.json

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions package.json
Expand Up @@ -137,11 +137,11 @@
"check-side-effects": "0.0.20",
"color": "3.0.0",
"colors": "1.1.2",
"commitizen": "^3.1.1",
"commitizen": "^4.0.3",
"cross-env": "5.1.3",
"cz-conventional-changelog": "1.2.0",
"dependency-cruiser": "^4.17.0",
"dtslint": "0.7.4",
"dependency-cruiser": "^4.27.3",
"dtslint": "^0.7.4",
"escape-string-regexp": "1.0.5",
"eslint": "4.17.0",
"eslint-plugin-jasmine": "^2.10.1",
Expand All @@ -152,8 +152,8 @@
"google-closure-compiler-js": "20170218.0.0",
"gzip-size": "4.1.0",
"klaw-sync": "3.0.2",
"lint-staged": "^9.2.5",
"lodash": "^4.17.11",
"lint-staged": "^8.1.6",
"lodash": "^4.17.15",
"minimist": "1.2.0",
"mkdirp": "0.5.1",
"mocha": "5.0.0",
Expand All @@ -169,15 +169,14 @@
"sinon": "4.3.0",
"sinon-chai": "2.14.0",
"source-map-support": "0.5.3",
"symbol-observable": "1.0.1",
"systemjs": "^0.21.0",
"ts-node": "6.1.0",
"tsconfig-paths": "3.2.0",
"tslint": "5.9.1",
"tslint-etc": "1.5.0",
"tslint-no-toplevel-property-access": "0.0.2",
"tslint-no-unused-expression-chai": "0.0.3",
"typescript": "^3.0.1",
"typescript": "3.5.3",
"validate-commit-msg": "2.14.0",
"webpack": "^4.31.0"
},
Expand Down
6 changes: 3 additions & 3 deletions spec-dtslint/Observable-spec.ts
Expand Up @@ -74,8 +74,8 @@ describe('pipe', () => {
const o = of('foo').pipe(a('1'), a('2'), a('3'), a('4'), a('5'), a('6'), a('7'), a('8'), a('9')); // $ExpectType Observable<"9">
});

it('should infer {} for more than 9 arguments', () => {
const o = of('foo').pipe(a('1'), a('2'), a('3'), a('4'), a('5'), a('6'), a('7'), a('8'), a('9'), a('10')); // $ExpectType Observable<{}>
it('should infer unknown for more than 9 arguments', () => {
const o = of('foo').pipe(a('1'), a('2'), a('3'), a('4'), a('5'), a('6'), a('7'), a('8'), a('9'), a('10')); // $ExpectType Observable<unknown>
});

it('should require a type assertion for more than 9 arguments', () => {
Expand Down Expand Up @@ -119,7 +119,7 @@ describe('pipe', () => {
});

it('should not enforce types beyond the 9th argument', () => {
const o = of('foo').pipe(a('1'), a('2'), a('3'), a('4'), a('5'), a('6'), a('7'), a('8'), a('9'), a('#', '10')); // $ExpectType Observable<{}>
const o = of('foo').pipe(a('1'), a('2'), a('3'), a('4'), a('5'), a('6'), a('7'), a('8'), a('9'), a('#', '10')); // $ExpectType Observable<unknown>
});

it('should support operators that return generics', () => {
Expand Down
4 changes: 2 additions & 2 deletions spec-dtslint/observables/combineLatest-spec.ts
Expand Up @@ -40,8 +40,8 @@ it('should accept 6 params', () => {
const o = combineLatest(a, b, c, d, e, f); // $ExpectType Observable<[A, B, C, D, E, F]>
});

it('should result in Observable<{}> for 7 or more params', () => {
const o = combineLatest(a, b, c, d, e, f, g); // $ExpectType Observable<{}>
it('should result in Observable<unknown> for 7 or more params', () => {
const o = combineLatest(a, b, c, d, e, f, g); // $ExpectType Observable<unknown>
});

it('should accept union types', () => {
Expand Down
4 changes: 2 additions & 2 deletions spec-dtslint/observables/concat-spec.ts
Expand Up @@ -28,8 +28,8 @@ it('should accept more than 6 params', () => {
const o = concat(of(1), of(2), of(3), of(4), of(5), of(6), of(7), of(8), of(9)); // $ExpectType Observable<number>
});

it('should return Observable<{}> for more than 6 different types of params', () => {
const o = concat(of(1), of('a'), of(2), of(true), of(3), of([1, 2, 3]), of(4)); // $ExpectType Observable<{}>
it('should return Observable<unknown> for more than 6 different types of params', () => {
const o = concat(of(1), of('a'), of(2), of(true), of(3), of([1, 2, 3]), of(4)); // $ExpectType Observable<string | number | boolean | number[]>
});

it('should accept scheduler after params', () => {
Expand Down
76 changes: 69 additions & 7 deletions spec-dtslint/observables/of-spec.ts
@@ -1,4 +1,4 @@
import { of, animationFrameScheduler } from 'rxjs';
import { of, animationFrameScheduler, queueScheduler } from 'rxjs';
import { A, B, C, D, E, F, G, H, I, J } from '../helpers';

const a = new A();
Expand All @@ -12,6 +12,16 @@ const h = new H();
const i = new I();
const j = new J();

it('should infer never with 0 params', () => {
const res = of(); // $ExpectType Observable<never>
});

it('forced generic should not cause an issue', () => {
const x: any = null;
const res = of<string>(); // $ExpectType Observable<string>
const res2 = of<string>(x); // $ExpectType Observable<string>
});

it('should infer correctly with 1 param', () => {
const res = of(new A()); // $ExpectType Observable<A>
});
Expand Down Expand Up @@ -52,13 +62,23 @@ it('should infer correcly with mono type of more than 9 params', () => {
const res = of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // $ExpectType Observable<number>
});

/*
TODO: The below test throws error where it should infer correctly with empty interface({})
shoudl be able to comment back in when https://github.com/ReactiveX/rxjs/issues/4502 is resolved
it('should not support mixed type of more than 9 params', () => {
const res = of(a, b, c, d, e, f, g, h, i, j); // $TODO: Shoule ExpectType Observable<{}>
it('should support mixed type of 9 params', () => {
const res = of(a, b, c, d, e, f, g, h, i, j); // $ExpectType Observable<A | B | C | D | E | F | G | H | I | J>
});

it('should support mixed type of 13 params', () => {
const res = of(a, b, c, d, e, f, g, h, i, j, '', true, 123, [1, 2, 3]); // $ExpectType Observable<string | number | boolean | number[] | A | B | C | D | E | F | G | H | I | J>
});

it('should support a rest of params', () => {
const arr = [a, b, c, d, e, f, g, h, i, j];
const res = of(...arr); // $ExpectType Observable<A | B | C | D | E | F | G | H | I | J>

const arr2 = ['test', 123, a];
const res2 = of(...arr2); // $ExpectType Observable<string | number | A>

const res3 = of(b, ...arr2, c, true); // $ExpectType Observable<string | number | boolean | A | B | C>
});
*/

it('should support scheduler', () => {
const res = of(a, animationFrameScheduler); // $ExpectType Observable<A>
Expand All @@ -67,3 +87,45 @@ it('should support scheduler', () => {
it('should infer correctly with array', () => {
const res = of([a, b, c]); // $ExpectType Observable<(A | B | C)[]>
});


// SchedulerLike inclusions (remove in v8)
it('should infer never with 0 params', () => {
const res = of(queueScheduler); // $ExpectType Observable<never>
});

it('should infer correctly with 1 param', () => {
const res = of(new A(), queueScheduler); // $ExpectType Observable<A>
});

it('should infer correcly with mixed type of 2 params', () => {
const res = of(a, b, queueScheduler); // $ExpectType Observable<A | B>
});

it('should infer correcly with mixed type of 3 params', () => {
const res = of(a, b, c, queueScheduler); // $ExpectType Observable<A | B | C>
});

it('should infer correcly with mixed type of 4 params', () => {
const res = of(a, b, c, d, queueScheduler); // $ExpectType Observable<A | B | C | D>
});

it('should infer correcly with mixed type of 5 params', () => {
const res = of(a, b, c, d, e, queueScheduler); // $ExpectType Observable<A | B | C | D | E>
});

it('should infer correcly with mixed type of 6 params', () => {
const res = of(a, b, c, d, e, f, queueScheduler); // $ExpectType Observable<A | B | C | D | E | F>
});

it('should infer correcly with mixed type of 7 params', () => {
const res = of(a, b, c, d, e, f, g, queueScheduler); // $ExpectType Observable<A | B | C | D | E | F | G>
});

it('should infer correcly with mixed type of 8 params', () => {
const res = of(a, b, c, d, e, f, g, h, queueScheduler); // $ExpectType Observable<A | B | C | D | E | F | G | H>
});

it('should infer correcly with mixed type of 9 params', () => {
const res = of(a, b, c, d, e, f, g, h, i, queueScheduler); // $ExpectType Observable<A | B | C | D | E | F | G | H | I>
});
6 changes: 3 additions & 3 deletions spec-dtslint/observables/race-spec.ts
Expand Up @@ -47,14 +47,14 @@ describe('race(a, b, c)', () => {
const o = race(a, a, a, a, a, a, a, a, a, a, a, a, a, a); // $ExpectType Observable<number>
});

it('should return {} for 6 or more arguments of different types', () => {
it('should return unknown for 6 or more arguments of different types', () => {
const a = of(1);
const b = of('a');
const c = of(true);
const d = of([1, 2, 3]);
const e = of(['blah']);
const f = of({ foo: 'bar' });
const o = race(a, b, c, d, e, f); // $ExpectType Observable<{}>
const o = race(a, b, c, d, e, f); // $ExpectType Observable<unknown>
});
});

Expand Down Expand Up @@ -107,7 +107,7 @@ describe('race([a, b, c])', () => {
const d = of([1, 2, 3]);
const e = of(['blah']);
const f = of({ foo: 'bar' });
const o = race([a, b, c, d, e, f]); // $ExpectType Observable<{}>
const o = race([a, b, c, d, e, f]); // $ExpectType Observable<unknown>
});
});

Expand Down
2 changes: 1 addition & 1 deletion spec-dtslint/operators/distinct-spec.ts
Expand Up @@ -7,7 +7,7 @@ it('should infer correctly', () => {

it('should accept a keySelector', () => {
interface Person { name: string; }
const o = of<Person>({ name: 'Tim' }).pipe(distinct(person => person.name)); // $ExpectType Observable<Person>
const o = of({ name: 'Tim' } as Person).pipe(distinct(person => person.name)); // $ExpectType Observable<Person>
});

it('should accept flushes', () => {
Expand Down
2 changes: 1 addition & 1 deletion spec-dtslint/operators/onErrorResumeNext-spec.ts
Expand Up @@ -43,7 +43,7 @@ it('should accept six inputs', () => {
});

it('should accept seven and more inputs', () => {
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(of(1), of(2), of('3'), of('4'), of(5), of('6'), of(7))); // $ExpectType Observable<string | {}>
const o = of('apple', 'banana', 'peach').pipe(onErrorResumeNext(of(1), of(2), of('3'), of('4'), of(5), of('6'), of(7))); // $ExpectType Observable<unknown>
const p = of('apple', 'banana', 'peach').pipe(onErrorResumeNext<string, string | number>(of(1), of(2), of('3'), of('4'), of(5), of('6'), of(7))); // $ExpectType Observable<string | number>
});

Expand Down
2 changes: 1 addition & 1 deletion spec-dtslint/operators/pluck-spec.ts
Expand Up @@ -26,7 +26,7 @@ it('should support nested object of 6 layer depth', () => {
});

it('should support nested object of more than 6 layer depth', () => {
const a = of({ a: { b: { c: { d: { e: { f: { name: 'abc' } } } } } } }).pipe(pluck('a', 'b', 'c', 'd', 'e', 'f', 'name')); // $ExpectType Observable<{}>
const a = of({ a: { b: { c: { d: { e: { f: { name: 'abc' } } } } } } }).pipe(pluck('a', 'b', 'c', 'd', 'e', 'f', 'name')); // $ExpectType Observable<unknown>
});

it('should accept existing keys only', () => {
Expand Down
6 changes: 1 addition & 5 deletions spec-dtslint/operators/publish-spec.ts
Expand Up @@ -2,11 +2,7 @@ import { of, Observable } from 'rxjs';
import { publish } from 'rxjs/operators';

it('should support empty parameter', () => {
// Here, TypeScript versions 3.1 and earlier infer Observable<any>. However,
// the next version infers Observable<number>. It's not possible to specify
// an upper bound for the TypeScript version used by dtslint, so an
// expectation cannot be applied.
const a = of(1, 2, 3).pipe(publish()); // $ExpectType Observable<any>
const a = of(1, 2, 3).pipe(publish()); // $ExpectType Observable<number>
});

it('should infer when type is specified', () => {
Expand Down
6 changes: 1 addition & 5 deletions spec-dtslint/operators/publishLast-spec.ts
Expand Up @@ -2,11 +2,7 @@ import { of } from 'rxjs';
import { publishLast } from 'rxjs/operators';

it('should accept empty parameter', () => {
// Here, TypeScript versions 3.1 and earlier infer Observable<any>. However,
// the next version infers Observable<number>. It's not possible to specify
// an upper bound for the TypeScript version used by dtslint, so an
// expectation cannot be applied.
const a = of(1, 2, 3).pipe(publishLast()); // $ExpectType Observable<any>
const a = of(1, 2, 3).pipe(publishLast()); // $ExpectType Observable<number>
});

it('should infer when type is specified', () => {
Expand Down
5 changes: 2 additions & 3 deletions spec-dtslint/operators/reduce-spec.ts
Expand Up @@ -31,9 +31,8 @@ it('should accept seed parameter of a different type', () => {
});

it('should act appropriately with no seed', () => {
// Because an observable of one value will just pass that value directly through the reducer,
// the below could be a number or a string.
const a = of(1, 2, 3).pipe(reduce((a: any, v) => '' + v)); // $ExpectType Observable<string | number>
// Starting in TS 3.5, the return type is inferred from the accumulator's type if it's provided without a seed.
const a = of(1, 2, 3).pipe(reduce((a: any, v) => '' + v)); // $ExpectType Observable<any>
const b = of(1, 2, 3).pipe(reduce((a, v) => v)); // $ExpectType Observable<number>
const c = of(1, 2, 3).pipe(reduce(() => {})); // $ExpectType Observable<number | void>
});
Expand Down
5 changes: 2 additions & 3 deletions spec-dtslint/operators/scan-spec.ts
Expand Up @@ -31,9 +31,8 @@ it('should accept seed parameter of a different type', () => {
});

it('should act appropriately with no seed', () => {
// Because an observable of one value will just pass that value directly through the reducer,
// the below could be a number or a string.
const a = of(1, 2, 3).pipe(scan((a: any, v) => '' + v)); // $ExpectType Observable<string | number>
// Starting in TS 3.5, the return type is inferred from the accumulator's type if it's provided without a seed.
const a = of(1, 2, 3).pipe(scan((a: any, v) => '' + v)); // $ExpectType Observable<any>
const b = of(1, 2, 3).pipe(scan((a, v) => v)); // $ExpectType Observable<number>
const c = of(1, 2, 3).pipe(scan(() => {})); // $ExpectType Observable<number | void>
});
Expand Down
2 changes: 1 addition & 1 deletion spec-dtslint/operators/withLatestFrom-spec.ts
Expand Up @@ -51,7 +51,7 @@ describe('withLatestFrom', () => {
const e = of('j', 'k', 'l');
const f = of('m', 'n', 'o');
const g = of('p', 'q', 'r');
const res = a.pipe(withLatestFrom(b, c, d, e, f, g)); // $ExpectType Observable<{}>
const res = a.pipe(withLatestFrom(b, c, d, e, f, g)); // $ExpectType Observable<unknown>
});
});

Expand Down
2 changes: 1 addition & 1 deletion spec-dtslint/operators/zip-spec.ts
Expand Up @@ -4,7 +4,7 @@ import { zip } from 'rxjs/operators';
it('should support rest parameter observables', () => {
const o = of(1); // $ExpectType Observable<number>
const z = [of(2)]; // $ExpectType Observable<number>[]
const a = o.pipe(zip(...z)); // $ExpectType Observable<{}>
const a = o.pipe(zip(...z)); // $ExpectType Observable<unknown>
});

it('should support rest parameter observables with type parameters', () => {
Expand Down
10 changes: 5 additions & 5 deletions spec-dtslint/util/pipe-spec.ts
Expand Up @@ -21,8 +21,8 @@ function a<I extends string, O extends string>(input: I, output: O): UnaryFuncti
return i => output;
}

it('should infer {} for no arguments', () => {
const o = pipe(); // $ExpectType UnaryFunction<{}, {}>
it('should infer unknown for no arguments', () => {
const o = pipe(); // $ExpectType UnaryFunction<unknown, unknown>
});

it('should infer for 1 argument', () => {
Expand Down Expand Up @@ -115,12 +115,12 @@ it('should return an explicit Observable type', () => {
const o = of('foo').pipe(staticPipe); // $ExpectType Observable<string>
});

it('should return Observable<{}> when T cannot be inferred', () => {
it('should return Observable<unknown> when T cannot be inferred', () => {
const customOperator = <T>() => (a: Observable<T>) => a;

// type can't be possibly be inferred here, so it's {} instead of T.
// type can't be possibly be inferred here
const staticPipe = pipe(customOperator());
const o = of('foo').pipe(staticPipe); // $ExpectType Observable<{}>
const o = of('foo').pipe(staticPipe); // $ExpectType Observable<unknown>
});

it('should return a non-narrowed type', () => {
Expand Down

0 comments on commit 56cbd22

Please sign in to comment.