-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(types): support passing union types to from
- Loading branch information
Showing
2 changed files
with
47 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { from, of, asyncScheduler } from 'rxjs'; | ||
|
||
it('should accept an array', () => { | ||
const o = from([1, 2, 3, 4]); // $ExpectType Observable<number> | ||
}); | ||
|
||
it('should accept a Promise', () => { | ||
const o = from(Promise.resolve('test')); // $ExpectType Observable<string> | ||
}); | ||
|
||
it('should accept an Iterable', () => { | ||
const iterable = (function*() { | ||
yield 42; | ||
}()); | ||
|
||
const o = from(iterable); // $ExpectType Observable<number> | ||
}); | ||
|
||
it('should accept an Observable', () => { | ||
const o = from(of('test')); // $ExpectType Observable<string> | ||
}); | ||
|
||
it('should accept union types', () => { | ||
const o = from(Math.random() > 0.5 ? of(123) : of('test')); // $ExpectType Observable<string | number> | ||
}); | ||
|
||
it('should accept Observable<Observable<number>>', () => { | ||
const o = from(of(of(123))); // $ExpectType Observable<Observable<number>> | ||
}); | ||
|
||
it('should accept Observable<number[]>', () => { | ||
const o = from(of([1, 2, 3])); // $ExpectType Observable<number[]> | ||
}); | ||
|
||
it('should accept an array of Observables', () => { | ||
const o = from([of(1), of(2), of(3)]); // $ExpectType Observable<Observable<number>> | ||
}); | ||
|
||
it('should accept an array of Inputs', () => { | ||
const iterable = (function*() { | ||
yield 42; | ||
}()); | ||
|
||
const o = from([of(1), ['test'], iterable]); // $ExpectType Observable<Observable<number> | IterableIterator<number> | string[]> | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters