-
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.
- Loading branch information
Showing
8 changed files
with
173 additions
and
11 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,42 @@ | ||
import { AsyncSubject } from 'rxjs'; | ||
|
||
describe('AsyncSubject', () => { | ||
it('should handle no generic appropriately', () => { | ||
const s1 = new AsyncSubject(); // $ExpectType AsyncSubject<unknown> | ||
s1.next(); // $ExpectError | ||
s1.next('test'); // $ExpectType void | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType unknown | ||
}); | ||
}); | ||
|
||
it('should handle a generic of string appropriately', () => { | ||
const s1 = new AsyncSubject<string>(); // $ExpectType AsyncSubject<string> | ||
s1.next(); // $ExpectError | ||
s1.next('test'); // $ExpectType void | ||
s1.next(32); // $ExpectError | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType string | ||
}); | ||
}); | ||
|
||
it('should handle a generic of void appropriately', () => { | ||
const s1 = new AsyncSubject<void>(); // $ExpectType AsyncSubject<void> | ||
s1.next(); // $ExpectType void | ||
s1.next(undefined); // $ExpectType void | ||
s1.next('test'); // $ExpectError | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType void | ||
}); | ||
}); | ||
|
||
describe('asObservable', () => { | ||
it('should return an observable of the same generic type', () => { | ||
const s1 = new AsyncSubject(); | ||
const o1 = s1.asObservable(); // $ExpectType Observable<unknown> | ||
|
||
const s2 = new AsyncSubject<string>(); | ||
const o2 = s2.asObservable(); // $ExpectType Observable<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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { BehaviorSubject } from 'rxjs'; | ||
|
||
describe('BehaviorSubject', () => { | ||
it('should handle no generic appropriately', () => { | ||
const s1 = new BehaviorSubject(); // $ExpectError | ||
}); | ||
|
||
it('should handle an argument of string appropriately', () => { | ||
const init = 'some string'; | ||
const s1 = new BehaviorSubject(init); // $ExpectType BehaviorSubject<string> | ||
s1.next(); // $ExpectError | ||
s1.next('test'); // $ExpectType void | ||
s1.next(32); // $ExpectError | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType string | ||
}); | ||
const v = s1.getValue(); // $ExpectType string | ||
}); | ||
|
||
it('should handle a generic of void appropriately', () => { | ||
const s1 = new BehaviorSubject<void>(undefined); // $ExpectType BehaviorSubject<void> | ||
s1.next(); // $ExpectType void | ||
s1.next('test'); // $ExpectError | ||
s1.next(32); // $ExpectError | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType void | ||
}); | ||
const v = s1.getValue(); // $ExpectType void | ||
}); | ||
|
||
describe('asObservable', () => { | ||
it('should return an observable of the same generic type', () => { | ||
const s1 = new BehaviorSubject('test'); | ||
const o1 = s1.asObservable(); // $ExpectType Observable<string> | ||
|
||
const s2 = new BehaviorSubject<void>(undefined); | ||
const o2 = s2.asObservable(); // $ExpectType Observable<void> | ||
}); | ||
}); | ||
}); |
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,42 @@ | ||
import { ReplaySubject } from 'rxjs'; | ||
|
||
describe('ReplaySubject', () => { | ||
it('should handle no generic appropriately', () => { | ||
const s1 = new ReplaySubject(); // $ExpectType ReplaySubject<unknown> | ||
s1.next(); // $ExpectError | ||
s1.next('test'); // $ExpectType void | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType unknown | ||
}); | ||
}); | ||
|
||
it('should handle a generic of string appropriately', () => { | ||
const s1 = new ReplaySubject<string>(); // $ExpectType ReplaySubject<string> | ||
s1.next(); // $ExpectError | ||
s1.next('test'); // $ExpectType void | ||
s1.next(32); // $ExpectError | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType string | ||
}); | ||
}); | ||
|
||
it('should handle a generic of void appropriately', () => { | ||
const s1 = new ReplaySubject<void>(); // $ExpectType ReplaySubject<void> | ||
s1.next(); // $ExpectType void | ||
s1.next(undefined); // $ExpectType void | ||
s1.next('test'); // $ExpectError | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType void | ||
}); | ||
}); | ||
|
||
describe('asObservable', () => { | ||
it('should return an observable of the same generic type', () => { | ||
const s1 = new ReplaySubject(); | ||
const o1 = s1.asObservable(); // $ExpectType Observable<unknown> | ||
|
||
const s2 = new ReplaySubject<string>(); | ||
const o2 = s2.asObservable(); // $ExpectType Observable<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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { Subject } from 'rxjs'; | ||
|
||
describe('Subject', () => { | ||
it('should handle no generic appropriately', () => { | ||
const s1 = new Subject(); // $ExpectType Subject<unknown> | ||
s1.next(); // $ExpectError | ||
s1.next('test'); // $ExpectType void | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType unknown | ||
}); | ||
}); | ||
|
||
it('should handle a generic of string appropriately', () => { | ||
const s1 = new Subject<string>(); // $ExpectType Subject<string> | ||
s1.next(); // $ExpectError | ||
s1.next('test'); // $ExpectType void | ||
s1.next(32); // $ExpectError | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType string | ||
}); | ||
}); | ||
|
||
it('should handle a generic of void appropriately', () => { | ||
const s1 = new Subject<void>(); // $ExpectType Subject<void> | ||
s1.next(); // $ExpectType void | ||
s1.next(undefined); // $ExpectType void | ||
s1.next('test'); // $ExpectError | ||
s1.subscribe(value => { | ||
const x = value; // $ExpectType void | ||
}); | ||
}); | ||
|
||
describe('asObservable', () => { | ||
it('should return an observable of the same generic type', () => { | ||
const s1 = new Subject(); | ||
const o1 = s1.asObservable(); // $ExpectType Observable<unknown> | ||
|
||
const s2 = new Subject<string>(); | ||
const o2 = s2.asObservable(); // $ExpectType Observable<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
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
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
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