|
1 |
| -import { of, asyncScheduler } from 'rxjs'; |
2 |
| -import { expand } from 'rxjs/operators'; |
3 |
| - |
4 |
| -it('should infer correctly', () => { |
5 |
| - const o = of(1, 2, 3).pipe(expand(value => of(value))); // $ExpectType Observable<number> |
6 |
| - const p = of(1, 2, 3).pipe(expand(value => [value])); // $ExpectType Observable<number> |
7 |
| - const q = of(1, 2, 3).pipe(expand(value => Promise.resolve(value))); // $ExpectType Observable<number> |
8 |
| -}); |
9 |
| - |
10 |
| -it('should infer correctly with a different type as the source', () => { |
11 |
| - const o = of(1, 2, 3).pipe(expand(value => of('foo'))); // $ExpectType Observable<string> |
12 |
| - const p = of(1, 2, 3).pipe(expand(value => ['foo'])); // $ExpectType Observable<string> |
13 |
| - const q = of(1, 2, 3).pipe(expand(value => Promise.resolve('foo'))); // $ExpectType Observable<string> |
14 |
| -}); |
15 |
| - |
16 |
| -it('should support a project function with index', () => { |
17 |
| - const o = of(1, 2, 3).pipe(expand((value, index) => of(index))); // $ExpectType Observable<number> |
18 |
| -}); |
19 |
| - |
20 |
| -it('should support concurrent parameter', () => { |
21 |
| - const o = of(1, 2, 3).pipe(expand(value => of(1), 47)); // $ExpectType Observable<number> |
22 |
| -}); |
23 |
| - |
24 |
| -it('should support a scheduler', () => { |
25 |
| - const o = of(1, 2, 3).pipe(expand(value => of(1), 47, asyncScheduler)); // $ExpectType Observable<number> |
26 |
| -}); |
27 |
| - |
28 |
| -it('should enforce types', () => { |
29 |
| - const o = of(1, 2, 3).pipe(expand()); // $ExpectError |
30 |
| -}); |
31 |
| - |
32 |
| -it('should enforce project types', () => { |
33 |
| - const o = of(1, 2, 3).pipe(expand((value: string, index) => of(1))); // $ExpectError |
34 |
| - const p = of(1, 2, 3).pipe(expand((value, index: string) => of(1))); // $ExpectError |
35 |
| -}); |
36 |
| - |
37 |
| -it('should enforce project return type', () => { |
38 |
| - const o = of(1, 2, 3).pipe(expand(value => 1)); // $ExpectError |
39 |
| -}); |
40 |
| - |
41 |
| -it('should enforce concurrent type', () => { |
42 |
| - const o = of(1, 2, 3).pipe(expand(value => of(1), 'foo')); // $ExpectError |
43 |
| -}); |
44 |
| - |
45 |
| -it('should enforce scheduler type', () => { |
46 |
| - const o = of(1, 2, 3).pipe(expand(value => of(1), 47, 'foo')); // $ExpectError |
47 |
| -}); |
48 |
| - |
49 |
| -it('should support union types', () => { |
50 |
| - const o = of(1).pipe(expand(x => typeof x === 'string' ? of(123) : of('test'))); // $ExpectType Observable<string | number> |
51 |
| -}); |
| 1 | +import { of, asyncScheduler } from 'rxjs'; |
| 2 | +import { expand } from 'rxjs/operators'; |
| 3 | + |
| 4 | +it('should infer correctly', () => { |
| 5 | + const o = of(1, 2, 3).pipe(expand(value => of(value))); // $ExpectType Observable<number> |
| 6 | + const p = of(1, 2, 3).pipe(expand(value => [value])); // $ExpectType Observable<number> |
| 7 | + const q = of(1, 2, 3).pipe(expand(value => Promise.resolve(value))); // $ExpectType Observable<number> |
| 8 | +}); |
| 9 | + |
| 10 | +it('should infer correctly with a different type as the source', () => { |
| 11 | + const o = of(1, 2, 3).pipe(expand(value => of('foo'))); // $ExpectType Observable<string> |
| 12 | + const p = of(1, 2, 3).pipe(expand(value => ['foo'])); // $ExpectType Observable<string> |
| 13 | + const q = of(1, 2, 3).pipe(expand(value => Promise.resolve('foo'))); // $ExpectType Observable<string> |
| 14 | +}); |
| 15 | + |
| 16 | +it('should support a project function with index', () => { |
| 17 | + const o = of(1, 2, 3).pipe(expand((value, index) => of(index))); // $ExpectType Observable<number> |
| 18 | +}); |
| 19 | + |
| 20 | +it('should support concurrent parameter', () => { |
| 21 | + const o = of(1, 2, 3).pipe(expand(value => of(1), 47)); // $ExpectType Observable<number> |
| 22 | +}); |
| 23 | + |
| 24 | +it('should enforce types', () => { |
| 25 | + const o = of(1, 2, 3).pipe(expand()); // $ExpectError |
| 26 | +}); |
| 27 | + |
| 28 | +it('should enforce project types', () => { |
| 29 | + const o = of(1, 2, 3).pipe(expand((value: string, index) => of(1))); // $ExpectError |
| 30 | + const p = of(1, 2, 3).pipe(expand((value, index: string) => of(1))); // $ExpectError |
| 31 | +}); |
| 32 | + |
| 33 | +it('should enforce project return type', () => { |
| 34 | + const o = of(1, 2, 3).pipe(expand(value => 1)); // $ExpectError |
| 35 | +}); |
| 36 | + |
| 37 | +it('should enforce concurrent type', () => { |
| 38 | + const o = of(1, 2, 3).pipe(expand(value => of(1), 'foo')); // $ExpectError |
| 39 | +}); |
| 40 | + |
| 41 | +it('should enforce scheduler type', () => { |
| 42 | + const o = of(1, 2, 3).pipe(expand(value => of(1), 47, 'foo')); // $ExpectError |
| 43 | +}); |
| 44 | + |
| 45 | +it('should support union types', () => { |
| 46 | + const o = of(1).pipe(expand(x => typeof x === 'string' ? of(123) : of('test'))); // $ExpectType Observable<string | number> |
| 47 | +}); |
0 commit comments