forked from ReactiveX/rxjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types-spec.ts
87 lines (74 loc) · 2.52 KB
/
types-spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import type {
Observable,
ObservedValueOf,
ObservedValueUnionFromArray,
ObservedValueTupleFromArray,
Cons,
Head,
Tail
} from 'rxjs';
import type { A, B, C } from './helpers';
describe('ObservedValueOf', () => {
it('should infer from an observable', () => {
let explicit: ObservedValueOf<Observable<A>>;
const inferred = explicit!; // $ExpectType A
});
it('should infer from an array', () => {
let explicit: ObservedValueOf<A[]>;
const inferred = explicit!; // $ExpectType A
});
it('should infer from a promise', () => {
let explicit: ObservedValueOf<Promise<A>>;
const inferred = explicit!; // $ExpectType A
});
});
describe('ObservedUnionFromArray', () => {
it('should infer from an array of observables', () => {
let explicit: ObservedValueUnionFromArray<[Observable<A>, Observable<B>]>;
const inferred = explicit!; // $ExpectType A | B
});
it('should infer from an array of arrays', () => {
let explicit: ObservedValueUnionFromArray<[A[], B[]]>;
const inferred = explicit!; // $ExpectType A | B
});
it('should infer from an array of promises', () => {
let explicit: ObservedValueUnionFromArray<[Promise<A>, Promise<B>]>;
const inferred = explicit!; // $ExpectType A | B
});
});
describe('ObservedTupleFromArray', () => {
it('should infer from an array of observables', () => {
let explicit: ObservedValueTupleFromArray<[Observable<A>, Observable<B>]>;
const inferred = explicit!; // $ExpectType [A, B]
});
it('should infer from an array of arrays', () => {
let explicit: ObservedValueTupleFromArray<[A[], B[]]>;
const inferred = explicit!; // $ExpectType [A, B]
});
it('should infer from an array of promises', () => {
let explicit: ObservedValueTupleFromArray<[Promise<A>, Promise<B>]>;
const inferred = explicit!; // $ExpectType [A, B]
});
});
describe('Cons', () => {
it('should construct a tuple with the specified type at the head', () => {
let explicit: Cons<A, [B, C]>;
const inferred = explicit!; // $ExpectType [A, B, C]
});
it('should support rest tuples', () => {
let explicit: Cons<A, B[]>;
const inferred = explicit!; // $ExpectType [arg: A, ...rest: B[]]
});
});
describe('Head', () => {
it('should return the head of a tuple', () => {
let explicit: Head<[A, B, C]>;
const inferred = explicit!; // $ExpectType A
});
});
describe('Tail', () => {
it('should return the tail of a tuple', () => {
let explicit: Tail<[A, B, C]>;
const inferred = explicit!; // $ExpectType [B, C]
});
});