|
| 1 | +import { from, of, asyncScheduler } from 'rxjs'; |
| 2 | + |
| 3 | +it('should accept an array', () => { |
| 4 | + const o = from([1, 2, 3, 4]); // $ExpectType Observable<number> |
| 5 | +}); |
| 6 | + |
| 7 | +it('should accept a Promise', () => { |
| 8 | + const o = from(Promise.resolve('test')); // $ExpectType Observable<string> |
| 9 | +}); |
| 10 | + |
| 11 | +it('should accept an Iterable', () => { |
| 12 | + const iterable = (function*() { |
| 13 | + yield 42; |
| 14 | + }()); |
| 15 | + |
| 16 | + const o = from(iterable); // $ExpectType Observable<number> |
| 17 | +}); |
| 18 | + |
| 19 | +it('should accept an Observable', () => { |
| 20 | + const o = from(of('test')); // $ExpectType Observable<string> |
| 21 | +}); |
| 22 | + |
| 23 | +it('should accept union types', () => { |
| 24 | + const o = from(Math.random() > 0.5 ? of(123) : of('test')); // $ExpectType Observable<string | number> |
| 25 | +}); |
| 26 | + |
| 27 | +it('should accept Observable<Observable<number>>', () => { |
| 28 | + const o = from(of(of(123))); // $ExpectType Observable<Observable<number>> |
| 29 | +}); |
| 30 | + |
| 31 | +it('should accept Observable<number[]>', () => { |
| 32 | + const o = from(of([1, 2, 3])); // $ExpectType Observable<number[]> |
| 33 | +}); |
| 34 | + |
| 35 | +it('should accept an array of Observables', () => { |
| 36 | + const o = from([of(1), of(2), of(3)]); // $ExpectType Observable<Observable<number>> |
| 37 | +}); |
| 38 | + |
| 39 | +it('should accept an array of Inputs', () => { |
| 40 | + const iterable = (function*() { |
| 41 | + yield 42; |
| 42 | + }()); |
| 43 | + |
| 44 | + const o = from([of(1), ['test'], iterable]); // $ExpectType Observable<Observable<number> | IterableIterator<number> | string[]> |
| 45 | +}); |
0 commit comments