|
1 | 1 | import { fromEvent } from 'rxjs';
|
2 | 2 | import { JQueryStyleEventEmitter } from '../../src/internal/observable/fromEvent';
|
3 |
| -import { A, B } from "../helpers"; |
| 3 | +import { A, B } from '../helpers'; |
4 | 4 |
|
5 |
| -declare const eventTargetSource: HTMLDocument; |
| 5 | +declare const eventTargetSource: EventTarget; |
| 6 | + |
| 7 | +it('should support an event target source', () => { |
| 8 | + const a = fromEvent(eventTargetSource, "click"); // $ExpectType Observable<Event> |
| 9 | +}); |
| 10 | + |
| 11 | +declare const documentSource: HTMLDocument; |
| 12 | + |
| 13 | +it('should support a document source', () => { |
| 14 | + const a = fromEvent(documentSource, "click"); // $ExpectType Observable<Event> |
| 15 | +}); |
6 | 16 |
|
7 | 17 | interface NodeStyleSource {
|
8 | 18 | addListener: (eventName: string | symbol, handler: (...args: any[]) => void) => this;
|
9 | 19 | removeListener: (eventName: string | symbol, handler: (...args: any[]) => void) => this;
|
10 | 20 | };
|
11 |
| -declare const nodeStyleSource : NodeStyleSource; |
12 |
| - |
13 |
| -declare const nodeCompatibleSource: { |
14 |
| - addListener: (eventName: string, handler: (...args: any[]) => void) => void; |
15 |
| - removeListener: (eventName: string, handler: (...args: any[]) => void) => void; |
16 |
| -}; |
17 | 21 |
|
18 |
| - |
19 |
| - |
20 |
| -it('should support an event target source', () => { |
21 |
| - const a = fromEvent(eventTargetSource, "click"); // $ExpectType Observable<Event> |
22 |
| -}); |
| 22 | +declare const nodeStyleSource : NodeStyleSource; |
23 | 23 |
|
24 | 24 | it('should support a node-style source', () => {
|
25 | 25 | const a = fromEvent(nodeStyleSource, "something"); // $ExpectType Observable<unknown>
|
26 | 26 | const b = fromEvent<B>(nodeStyleSource, "something"); // $ExpectType Observable<B>
|
27 | 27 | });
|
28 | 28 |
|
| 29 | +declare const nodeCompatibleSource: { |
| 30 | + addListener: (eventName: string, handler: (...args: any[]) => void) => void; |
| 31 | + removeListener: (eventName: string, handler: (...args: any[]) => void) => void; |
| 32 | +}; |
| 33 | + |
29 | 34 | it('should support a node-compatible source', () => {
|
30 | 35 | const a = fromEvent(nodeCompatibleSource, "something"); // $ExpectType Observable<unknown>
|
31 | 36 | const b = fromEvent<B>(nodeCompatibleSource, "something"); // $ExpectType Observable<B>
|
32 | 37 | });
|
33 | 38 |
|
34 | 39 | declare const jQueryStyleSource: JQueryStyleEventEmitter<A, B>;
|
| 40 | + |
35 | 41 | it('should support a jQuery-style source', () => {
|
36 | 42 | const a = fromEvent(jQueryStyleSource, "something"); // $ExpectType Observable<B>
|
37 | 43 | const b = fromEvent<B>(jQueryStyleSource, "something"); // $ExpectType Observable<B>
|
|
0 commit comments