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

feat: removed deprecated call pattern with resultSelector #7156

Merged
Merged
20 changes: 0 additions & 20 deletions spec-dtslint/operators/concatMap-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,6 @@ it('should support a projector that takes an index', () => {
const o = of(1, 2, 3).pipe(concatMap((p, index) => of(Boolean(p)))); // $ExpectType Observable<boolean>
});

it('should infer correctly by using the resultSelector first parameter', () => {
const o = of(1, 2, 3).pipe(concatMap(p => of(Boolean(p)), a => a)); // $ExpectType Observable<number>
});

it('should infer correctly by using the resultSelector second parameter', () => {
const o = of(1, 2, 3).pipe(concatMap(p => of(Boolean(p)), (a, b) => b)); // $ExpectType Observable<boolean>
});

it('should support a resultSelector that takes an inner index', () => {
const o = of(1, 2, 3).pipe(concatMap(p => of(Boolean(p)), (a, b, innerIndex) => a)); // $ExpectType Observable<number>
});

it('should support a resultSelector that takes an inner and outer index', () => {
const o = of(1, 2, 3).pipe(concatMap(p => of(Boolean(p)), (a, b, innerIndex, outerIndex) => a)); // $ExpectType Observable<number>
});

it('should support an undefined resultSelector', () => {
const o = of(1, 2, 3).pipe(concatMap(p => of(Boolean(p)), undefined)); // $ExpectType Observable<boolean>
});

it('should support union-type projections', () => {
const o = of(Math.random()).pipe(concatMap(n => n > 0.5 ? of('life') : of(42))); // $ExpectType Observable<string | number>
});
Expand Down
22 changes: 1 addition & 21 deletions spec-dtslint/operators/concatMapTo-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@ it('should infer correctly with a Promise', () => {
const o = of(1, 2, 3).pipe(concatMapTo(new Promise<string>(() => {}))); // $ExpectType Observable<string>
});

it('should infer correctly by using the resultSelector first parameter', () => {
const o = of(1, 2, 3).pipe(concatMapTo(of('foo'), a => a)); // $ExpectType Observable<number>
});

it('should infer correctly by using the resultSelector second parameter', () => {
const o = of(1, 2, 3).pipe(concatMapTo(of('foo'), (a, b) => b)); // $ExpectType Observable<string>
});

it('should support a resultSelector that takes an inner index', () => {
const o = of(1, 2, 3).pipe(concatMapTo(of('foo'), (a, b, innerIndex) => a)); // $ExpectType Observable<number>
});

it('should support a resultSelector that takes an inner and outer index', () => {
const o = of(1, 2, 3).pipe(concatMapTo(of('foo'), (a, b, innerIndex, outerIndex) => a)); // $ExpectType Observable<number>
});

it('should support an undefined resultSelector', () => {
const o = of(1, 2, 3).pipe(concatMapTo(of('foo'), undefined)); // $ExpectType Observable<string>
});

it('should support union types', () => {
const s = Math.random() > 0.5 ? of(123) : of('abc');
const r = of(1, 2, 3).pipe(concatMapTo(s)); // $ExpectType Observable<string | number>
Expand Down Expand Up @@ -66,4 +46,4 @@ it('should produce `Observable<never>` when mapping to an `ObservableInput<never

it('should be deprecated', () => {
const o = of(1, 2, 3).pipe(concatMapTo(of(true))); // $ExpectDeprecation
});
});
20 changes: 0 additions & 20 deletions spec-dtslint/operators/exhaustMap-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,6 @@ it('should support a projector that takes an index', () => {
const o = of(1, 2, 3).pipe(exhaustMap((p, index) => of(Boolean(p)))); // $ExpectType Observable<boolean>
});

it('should infer correctly by using the resultSelector first parameter', () => {
const o = of(1, 2, 3).pipe(exhaustMap(p => of(Boolean(p)), a => a)); // $ExpectType Observable<number>
});

it('should infer correctly by using the resultSelector second parameter', () => {
const o = of(1, 2, 3).pipe(exhaustMap(p => of(Boolean(p)), (a, b) => b)); // $ExpectType Observable<boolean>
});

it('should support a resultSelector that takes an inner index', () => {
const o = of(1, 2, 3).pipe(exhaustMap(p => of(Boolean(p)), (a, b, innerIndex) => a)); // $ExpectType Observable<number>
});

it('should support a resultSelector that takes an inner and outer index', () => {
const o = of(1, 2, 3).pipe(exhaustMap(p => of(Boolean(p)), (a, b, innerIndex, outerIndex) => a)); // $ExpectType Observable<number>
});

it('should support an undefined resultSelector', () => {
const o = of(1, 2, 3).pipe(exhaustMap(p => of(Boolean(p)), undefined)); // $ExpectType Observable<boolean>
});

it('should report projections to union types', () => {
const o = of(Math.random()).pipe(exhaustMap(n => n > 0.5 ? of('life') : of(42))); // $ExpectType Observable<string | number>
});
Expand Down
40 changes: 0 additions & 40 deletions spec-dtslint/operators/mergeMap-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,10 @@ it('should support a projector that takes an index', () => {
const o = of(1, 2, 3).pipe(mergeMap((p, index) => of(Boolean(p)))); // $ExpectType Observable<boolean>
});

it('should infer correctly by using the resultSelector first parameter', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), a => a)); // $ExpectType Observable<number>
});

it('should infer correctly by using the resultSelector second parameter', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), (a, b) => b)); // $ExpectType Observable<boolean>
});

it('should support a resultSelector that takes an inner index', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), (a, b, innerIndex) => a)); // $ExpectType Observable<number>
});

it('should support a resultSelector that takes an inner and outer index', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), (a, b, innerIndex, outerIndex) => a)); // $ExpectType Observable<number>
});

it('should support an undefined resultSelector', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), undefined)); // $ExpectType Observable<boolean>
});

it('should support a concurrent parameter', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), 4)); // $ExpectType Observable<boolean>
});

it('should support a resultSelector and concurrent parameter', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), (a, b) => b, 4)); // $ExpectType Observable<boolean>
});

it('should support a undefined resultSelector and concurrent parameter', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), undefined, 4)); // $ExpectType Observable<boolean>
});

it('should support union-type projections', () => {
const o = of(Math.random()).pipe(mergeMap(n => n > 0.5 ? of('life') : of(42))); // $ExpectType Observable<string | number>
});
Expand All @@ -57,18 +29,6 @@ it('should enforce the return type', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => p)); // $ExpectError
});

it('should enforce types of the concurrent parameter', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), '4')); // $ExpectError
});

it('should enforce types of the concurrent parameter with a resultSelector', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), (a => a), '4')); // $ExpectError
});

it('should enforce types of the concurrent parameter with an undefined resultSelector', () => {
const o = of(1, 2, 3).pipe(mergeMap(p => of(Boolean(p)), undefined, '4')); // $ExpectError
});

it('should produce `Observable<never>` when mapping to an `ObservableInput<never>`', () => {
const o = of(1, 2, 3).pipe(mergeMap(n => Promise.reject())); // $ExpectType Observable<never>
});
22 changes: 1 addition & 21 deletions spec-dtslint/operators/mergeMapTo-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,6 @@ it('should support a concurrent parameter', () => {
const o = of(1, 2, 3).pipe(mergeMapTo(of('foo'), 4)); // $ExpectType Observable<string>
});

it('should infer correctly by using the resultSelector first parameter', () => {
const o = of(1, 2, 3).pipe(mergeMapTo(of('foo'), a => a)); // $ExpectType Observable<number>
});

it('should infer correctly by using the resultSelector second parameter', () => {
const o = of(1, 2, 3).pipe(mergeMapTo(of('foo'), (a, b) => b)); // $ExpectType Observable<string>
});

it('should support a resultSelector that takes an inner index', () => {
const o = of(1, 2, 3).pipe(mergeMapTo(of('foo'), (a, b, innerIndex) => a)); // $ExpectType Observable<number>
});

it('should support a resultSelector that takes an inner and outer index', () => {
const o = of(1, 2, 3).pipe(mergeMapTo(of('foo'), (a, b, innerIndex, outerIndex) => a)); // $ExpectType Observable<number>
});

it('should support a resultSelector and concurrent parameter', () => {
const o = of(1, 2, 3).pipe(mergeMapTo(of('foo'), (a, b) => b, 4)); // $ExpectType Observable<string>
});

it('should support union-type projections with empty streams', () => {
const o = of(1, 2, 3).pipe(mergeMapTo(Math.random() < 0.5 ? of(123) : of())); // $ExpectType Observable<number>
});
Expand Down Expand Up @@ -78,4 +58,4 @@ it('should produce `Observable<never>` when mapping to an `ObservableInput<never

it('should be deprecated', () => {
const o = of(1, 2, 3).pipe(mergeMapTo(of(true))); // $ExpectDeprecation
});
});
20 changes: 0 additions & 20 deletions spec-dtslint/operators/switchMap-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,6 @@ it('should support a projector that takes an index', () => {
const o = of(1, 2, 3).pipe(switchMap(p => of(Boolean(p)))); // $ExpectType Observable<boolean>
});

it('should infer correctly by using the resultSelector first parameter', () => {
const o = of(1, 2, 3).pipe(switchMap(p => of(Boolean(p)), a => a)); // $ExpectType Observable<number>
});

it('should infer correctly by using the resultSelector second parameter', () => {
const o = of(1, 2, 3).pipe(switchMap(p => of(Boolean(p)), (a, b) => b)); // $ExpectType Observable<boolean>
});

it('should support a resultSelector that takes an inner index', () => {
const o = of(1, 2, 3).pipe(switchMap(p => of(Boolean(p)), (a, b, i) => a)); // $ExpectType Observable<number>
});

it('should support a resultSelector that takes an inner and outer index', () => {
const o = of(1, 2, 3).pipe(switchMap(p => of(Boolean(p)), (a, b, i, ii) => a)); // $ExpectType Observable<number>
});

it('should support an undefined resultSelector', () => {
const o = of(1, 2, 3).pipe(switchMap(p => of(Boolean(p)), undefined)); // $ExpectType Observable<boolean>
});

it('should support union-type projections with empty streams', () => {
const o = of(1, 2, 3).pipe(switchMap(n => Math.random() < 0.5 ? of(123) : of())); // $ExpectType Observable<number>
});
Expand Down
22 changes: 1 addition & 21 deletions spec-dtslint/operators/switchMapTo-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,6 @@ it('should infer correctly with a Promise', () => {
const o = of(1, 2, 3).pipe(switchMapTo(new Promise<string>(() => {}))); // $ExpectType Observable<string>
});

it('should infer correctly by using the resultSelector first parameter', () => {
const o = of(1, 2, 3).pipe(switchMapTo(of('foo'), a => a)); // $ExpectType Observable<number>
});

it('should infer correctly by using the resultSelector second parameter', () => {
const o = of(1, 2, 3).pipe(switchMapTo(of('foo'), (a, b) => b)); // $ExpectType Observable<string>
});

it('should support a resultSelector that takes an inner index', () => {
const o = of(1, 2, 3).pipe(switchMapTo(of('foo'), (a, b, innerIndex) => a)); // $ExpectType Observable<number>
});

it('should support a resultSelector that takes an inner and outer index', () => {
const o = of(1, 2, 3).pipe(switchMapTo(of('foo'), (a, b, innerIndex, outerIndex) => a)); // $ExpectType Observable<number>
});

it('should support an undefined resultSelector', () => {
const o = of(1, 2, 3).pipe(switchMapTo(of('foo'), undefined)); // $ExpectType Observable<string>
});

it('should support union-type projections with empty streams', () => {
const o = of(1, 2, 3).pipe(switchMapTo(Math.random() < 0.5 ? of(123) : of())); // $ExpectType Observable<number>
});
Expand All @@ -61,4 +41,4 @@ it('should produce `Observable<never>` when mapping to an `ObservableInput<never

it('should be deprecated', () => {
const o = of(1, 2, 3).pipe(switchMapTo(of(true))); // $ExpectDeprecation
});
});
51 changes: 0 additions & 51 deletions spec/operators/concatMap-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,57 +27,6 @@ describe('Observable.prototype.concatMap', () => {
});
});

it('should support the deprecated resultSelector', () => {
const results: Array<number[]> = [];

of(1, 2, 3)
.pipe(
concatMap(
(x) => of(x, x + 1, x + 2),
(a, b, i, ii) => [a, b, i, ii]
)
)
.subscribe({
next(value) {
results.push(value);
},
error(err) {
throw err;
},
complete() {
expect(results).to.deep.equal([
[1, 1, 0, 0],
[1, 2, 0, 1],
[1, 3, 0, 2],
[2, 2, 1, 0],
[2, 3, 1, 1],
[2, 4, 1, 2],
[3, 3, 2, 0],
[3, 4, 2, 1],
[3, 5, 2, 2],
]);
},
});
});

it('should support a void resultSelector (still deprecated)', () => {
const results: number[] = [];

of(1, 2, 3)
.pipe(concatMap((x) => of(x, x + 1, x + 2), void 0))
.subscribe({
next(value) {
results.push(value);
},
error(err) {
throw err;
},
complete() {
expect(results).to.deep.equal([1, 2, 3, 2, 3, 4, 3, 4, 5]);
},
});
});

it('should concatenate many regular interval inners', () => {
testScheduler.run(({ hot, cold, expectObservable, expectSubscriptions }) => {
const a = cold(' --a-a-a-(a|) ');
Expand Down
46 changes: 0 additions & 46 deletions spec/operators/concatMapTo-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,52 +27,6 @@ describe('concatMapTo', () => {
});
});

it('should support the deprecated resultSelector', () => {
const results: Array<number[]> = [];

of(1, 2, 3)
.pipe(concatMapTo(of(4, 5, 6), (a, b, i, ii) => [a, b, i, ii]))
.subscribe({
next(value) {
results.push(value);
},
error(err) {
throw err;
},
complete() {
expect(results).to.deep.equal([
[1, 4, 0, 0],
[1, 5, 0, 1],
[1, 6, 0, 2],
[2, 4, 1, 0],
[2, 5, 1, 1],
[2, 6, 1, 2],
[3, 4, 2, 0],
[3, 5, 2, 1],
[3, 6, 2, 2],
]);
},
});
});

it('should support a void resultSelector (still deprecated)', () => {
const results: number[] = [];

of(1, 2, 3)
.pipe(concatMapTo(of(4, 5, 6), void 0))
.subscribe({
next(value) {
results.push(value);
},
error(err) {
throw err;
},
complete() {
expect(results).to.deep.equal([4, 5, 6, 4, 5, 6, 4, 5, 6]);
},
});
});

it('should concatMapTo many outer values to many inner values', () => {
testScheduler.run(({ cold, hot, expectObservable, expectSubscriptions }) => {
const values = { i: 'foo', j: 'bar', k: 'baz', l: 'qux' };
Expand Down
Loading