forked from ReactiveX/rxjs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(dtslint): change of observable static function dtslint test to u…
…se helper (ReactiveX#4093)
- Loading branch information
Showing
2 changed files
with
48 additions
and
13 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,23 @@ | ||
import { of } from 'rxjs'; | ||
|
||
export class A { a = 0; } | ||
export class B { b = 0; } | ||
export class C { c = 0; } | ||
export class D { d = 0; } | ||
export class E { e = 0; } | ||
export class F { f = 0; } | ||
export class G { g = 0; } | ||
export class H { h = 0; } | ||
export class I { i = 0; } | ||
export class J { j = 0; } | ||
|
||
export const a = of(new A()); | ||
export const b = of(new B()); | ||
export const c = of(new C()); | ||
export const d = of(new D()); | ||
export const e = of(new E()); | ||
export const f = of(new F()); | ||
export const g = of(new G()); | ||
export const h = of(new H()); | ||
export const i = of(new I()); | ||
export const j = of(new J()); |
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 |
---|---|---|
@@ -1,53 +1,65 @@ | ||
import { of, animationFrameScheduler } from 'rxjs'; | ||
import { A, B, C, D, E, F, G, H, I, J } from '../helpers'; | ||
|
||
const a = new A(); | ||
const b = new B(); | ||
const c = new C(); | ||
const d = new D(); | ||
const e = new E(); | ||
const f = new F(); | ||
const g = new G(); | ||
const h = new H(); | ||
const i = new I(); | ||
const j = new J(); | ||
|
||
it('should infer correctly with 1 param', () => { | ||
const a = of(1); | ||
const res = of(new A()); // $ExpectType Observable<A> | ||
}); | ||
|
||
it('should infer correcly with mixed type of 2 params', () => { | ||
const a = of(1, 'a'); // $ExpectType Observable<string | number> | ||
const res = of(a, b); // $ExpectType Observable<A | B> | ||
}); | ||
|
||
it('should infer correcly with mixed type of 3 params', () => { | ||
const a = of(1, 'a', 2); // $ExpectType Observable<string | number> | ||
const res = of(a, b, c); // $ExpectType Observable<A | B | C> | ||
}); | ||
|
||
it('should infer correcly with mixed type of 4 params', () => { | ||
const a = of(1, 'a', 2, 3); // $ExpectType Observable<string | number> | ||
const res = of(a, b, c, d); // $ExpectType Observable<A | B | C | D> | ||
}); | ||
|
||
it('should infer correcly with mixed type of 5 params', () => { | ||
const a = of(1, 'a', 2, 3, 4); // $ExpectType Observable<string | number> | ||
const res = of(a, b, c, d, e); // $ExpectType Observable<A | B | C | D | E> | ||
}); | ||
|
||
it('should infer correcly with mixed type of 6 params', () => { | ||
const a = of(1, 'a', 2, 3, 4, 5); // $ExpectType Observable<string | number> | ||
const res = of(a, b, c, d, e, f); // $ExpectType Observable<A | B | C | D | E | F> | ||
}); | ||
|
||
it('should infer correcly with mixed type of 7 params', () => { | ||
const a = of(1, 'a', 2, 3, 4, 5, 6); // $ExpectType Observable<string | number> | ||
const res = of(a, b, c, d, e, f, g); // $ExpectType Observable<A | B | C | D | E | F | G> | ||
}); | ||
|
||
it('should infer correcly with mixed type of 8 params', () => { | ||
const a = of(1, 'a', 2, 3, 4, 5, 6, 7); // $ExpectType Observable<string | number> | ||
const res = of(a, b, c, d, e, f, g, h); // $ExpectType Observable<A | B | C | D | E | F | G | H> | ||
}); | ||
|
||
it('should infer correcly with mixed type of 9 params', () => { | ||
const a = of(1, 'a', 2, 3, 4, 5, 6, 7, 8); // $ExpectType Observable<string | number> | ||
const res = of(a, b, c, d, e, f, g, h, i); // $ExpectType Observable<A | B | C | D | E | F | G | H | I> | ||
}); | ||
|
||
it('should infer correcly with mono type of more than 9 params', () => { | ||
const a = of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // $ExpectType Observable<number> | ||
const res = of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10); // $ExpectType Observable<number> | ||
}); | ||
|
||
it('should not support mixed type of more than 9 params', () => { | ||
const a = of(1, 'a', 2, 3, 4, 5, 6, 7, 8, 9); // $ExpectError | ||
const res = of(a, b, c, d, e, f, g, h, i, j); // $ExpectError | ||
}); | ||
|
||
it('should support scheduler', () => { | ||
const a = of(1, animationFrameScheduler); // $ExpectType Observable<number> | ||
const res = of(a, animationFrameScheduler); // $ExpectType Observable<A> | ||
}); | ||
|
||
it('should infer correctly with array', () => { | ||
const a = of([1, 2, 3]); // $ExpectType Observable<number[]> | ||
const res = of([a, b, c]); // $ExpectType Observable<(A | B | C)[]> | ||
}); |