mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-10-04 06:47:03 +00:00
Add ChildNode to union in fireEvent element arg (#42215)
* Add ChildNode to union in fireEvent element arg * Add ChildNode test to eventTest() * Changing ChildNode to its super type Node for typescript@3.0 compatibility
This commit is contained in:
+3
-3
@@ -83,12 +83,12 @@ export type EventType =
|
||||
| 'gotPointerCapture'
|
||||
| 'lostPointerCapture';
|
||||
|
||||
export type FireFunction = (element: Document | Element | Window, event: Event) => boolean;
|
||||
export type FireFunction = (element: Document | Element | Window | Node, event: Event) => boolean;
|
||||
export type FireObject = {
|
||||
[K in EventType]: (element: Document | Element | Window, options?: {}) => boolean;
|
||||
[K in EventType]: (element: Document | Element | Window | Node, options?: {}) => boolean;
|
||||
};
|
||||
export type CreateObject = {
|
||||
[K in EventType]: (element: Document | Element | Window, options?: {}) => Event;
|
||||
[K in EventType]: (element: Document | Element | Window | Node, options?: {}) => Event;
|
||||
};
|
||||
|
||||
export const createEvent: CreateObject;
|
||||
|
||||
@@ -51,4 +51,16 @@ function eventTest() {
|
||||
location: 'http://www.example.com/?page=1',
|
||||
state: { page: 1 },
|
||||
});
|
||||
|
||||
// HTMLElement
|
||||
const element = document.createElement('div');
|
||||
fireEvent.click(getByText(element, 'foo'));
|
||||
|
||||
// ChildNode
|
||||
const child = document.createElement('div');
|
||||
element.appendChild(child);
|
||||
if (!element.firstChild) { // Narrow Type
|
||||
throw new Error(`Can't find firstChild`);
|
||||
}
|
||||
fireEvent.click(element.firstChild);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user