Skip to content

Commit a835adc

Browse files
authored
test: add thisArg deprecation tests (#6377)
1 parent f1b95cc commit a835adc

File tree

6 files changed

+40
-0
lines changed

6 files changed

+40
-0
lines changed

spec-dtslint/observables/partition-spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,10 @@ it('should support this with predicate', () => {
4646
return val < limit;
4747
}, thisArg);
4848
});
49+
50+
it('should deprecate thisArg usage', () => {
51+
const a = partition(of(1, 2, 3), Boolean); // $ExpectNoDeprecation
52+
const b = partition(of(1, 2, 3), Boolean, {}); // $ExpectDeprecation
53+
const c = partition(of(1, 2, 3), (value) => Boolean(value)); // $ExpectNoDeprecation
54+
const d = partition(of(1, 2, 3), (value) => Boolean(value), {}); // $ExpectDeprecation
55+
});

spec-dtslint/operators/every-spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,11 @@ it('should support this', () => {
5151
const limit = this.limit; // $ExpectType number
5252
return val < limit;
5353
}, thisArg));
54+
});
55+
56+
it('should deprecate thisArg usage', () => {
57+
const a = of(1, 2, 3).pipe(every(Boolean)); // $ExpectNoDeprecation
58+
const b = of(1, 2, 3).pipe(every(Boolean, {})); // $ExpectDeprecation
59+
const c = of(1, 2, 3).pipe(every((value) => Boolean(value))); // $ExpectNoDeprecation
60+
const d = of(1, 2, 3).pipe(every((value) => Boolean(value), {})); // $ExpectDeprecation
5461
});

spec-dtslint/operators/filter-spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,11 @@ it('should support this', () => {
9090
const limit = this.limit; // $ExpectType number
9191
return val < limit;
9292
}, thisArg));
93+
});
94+
95+
it('should deprecate thisArg usage', () => {
96+
const a = of(1, 2, 3).pipe(filter(Boolean)); // $ExpectNoDeprecation
97+
const b = of(1, 2, 3).pipe(filter(Boolean, {})); // $ExpectDeprecation
98+
const c = of(1, 2, 3).pipe(filter((value) => Boolean(value))); // $ExpectNoDeprecation
99+
const d = of(1, 2, 3).pipe(filter((value) => Boolean(value), {})); // $ExpectDeprecation
93100
});

spec-dtslint/operators/find-spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,11 @@ it('should support this', () => {
4040
const wanted = this.wanted; // $ExpectType number
4141
return val < wanted;
4242
}, thisArg));
43+
});
44+
45+
it('should deprecate thisArg usage', () => {
46+
const a = of(1, 2, 3).pipe(find(Boolean)); // $ExpectNoDeprecation
47+
const b = of(1, 2, 3).pipe(find(Boolean, {})); // $ExpectDeprecation
48+
const c = of(1, 2, 3).pipe(find((value) => Boolean(value))); // $ExpectNoDeprecation
49+
const d = of(1, 2, 3).pipe(find((value) => Boolean(value), {})); // $ExpectDeprecation
4350
});

spec-dtslint/operators/findIndex-spec.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,11 @@ it('should support this', () => {
4949
const wanted = this.wanted; // $ExpectType number
5050
return val < wanted;
5151
}, thisArg));
52+
});
53+
54+
it('should deprecate thisArg usage', () => {
55+
const a = of(1, 2, 3).pipe(findIndex(Boolean)); // $ExpectNoDeprecation
56+
const b = of(1, 2, 3).pipe(findIndex(Boolean, {})); // $ExpectDeprecation
57+
const c = of(1, 2, 3).pipe(findIndex((value) => Boolean(value))); // $ExpectNoDeprecation
58+
const d = of(1, 2, 3).pipe(findIndex((value) => Boolean(value), {})); // $ExpectDeprecation
5259
});

spec-dtslint/operators/map-spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,8 @@ it('should support this', () => {
3333
return val < limit ? val : limit;
3434
}, thisArg));
3535
});
36+
37+
it('should deprecate thisArg usage', () => {
38+
const a = of(1, 2, 3).pipe(map((value) => value)); // $ExpectNoDeprecation
39+
const b = of(1, 2, 3).pipe(map((value) => value, {})); // $ExpectDeprecation
40+
});

0 commit comments

Comments
 (0)