|
1 |
| -import {query, querySelectorAll, closest, getAttribute, namedItem} from "../index"; |
| 1 | +import {query, querySelectorAll, closest, getAttribute, namedItem} from '../index' |
2 | 2 |
|
3 |
| -const bodyElement1 = query(document, 'body'); |
4 |
| -const bodyElement2 = query(document, 'body', HTMLBodyElement); |
5 |
| -const bodyElement3 = query<HTMLBodyElement>(document, 'body'); |
6 |
| -const bodyElement4 = query<HTMLBodyElement>(document, 'body', HTMLBodyElement); |
| 3 | +const bodyElement1 = query(document, 'body') |
| 4 | +const bodyElement2 = query(document, 'body', HTMLBodyElement) |
| 5 | +const bodyElement3 = query<HTMLBodyElement>(document, 'body') |
| 6 | +const bodyElement4 = query<HTMLBodyElement>(document, 'body', HTMLBodyElement) |
7 | 7 |
|
8 |
| -const formElements1 = querySelectorAll(bodyElement1, '.js-comment-form'); |
9 |
| -const formElements2 = querySelectorAll(bodyElement2, '.js-comment-form', HTMLFormElement); |
10 |
| -const formElements3 = querySelectorAll<HTMLFormElement>(bodyElement3, '.js-comment-form'); |
11 |
| -const formElements4 = querySelectorAll<HTMLFormElement>(bodyElement4, '.js-comment-form', HTMLFormElement); |
| 8 | +const formElements1 = querySelectorAll(bodyElement1, '.js-comment-form') |
| 9 | +const formElements2 = querySelectorAll(bodyElement2, '.js-comment-form', HTMLFormElement) |
| 10 | +const formElements3 = querySelectorAll<HTMLFormElement>(bodyElement3, '.js-comment-form') |
| 11 | +const formElements4 = querySelectorAll<HTMLFormElement>(bodyElement4, '.js-comment-form', HTMLFormElement) |
12 | 12 |
|
13 |
| -const htmlElement1 = closest(bodyElement1, 'html'); |
14 |
| -const htmlElement2 = closest(bodyElement2, 'html', HTMLHtmlElement); |
15 |
| -const htmlElement3 = closest<HTMLHtmlElement>(bodyElement3, 'html'); |
16 |
| -const htmlElement4 = closest<HTMLHtmlElement>(bodyElement4, 'html', HTMLHtmlElement); |
| 13 | +const htmlElement1 = closest(bodyElement1, 'html') |
| 14 | +const htmlElement2 = closest(bodyElement2, 'html', HTMLHtmlElement) |
| 15 | +const htmlElement3 = closest<HTMLHtmlElement>(bodyElement3, 'html') |
| 16 | +const htmlElement4 = closest<HTMLHtmlElement>(bodyElement4, 'html', HTMLHtmlElement) |
17 | 17 |
|
18 |
| -const bodyThing = getAttribute(bodyElement1, 'data-things'); |
| 18 | +const bodyThing = getAttribute(bodyElement1, 'data-things') |
19 | 19 |
|
20 |
| -const commentForm = formElements3[0]; |
| 20 | +const commentForm = formElements3[0] |
21 | 21 |
|
22 |
| -const usernameField = namedItem(commentForm, 'username'); |
23 |
| -const nameField = namedItem(commentForm, 'name', HTMLInputElement); |
24 |
| -const emailField = namedItem<HTMLInputElement>(commentForm, 'email', HTMLInputElement); |
25 |
| -const mailinglistsField = namedItem<RadioNodeList>(commentForm, 'mailinglists', RadioNodeList); |
26 |
| -const locationField = namedItem<HTMLSelectElement>(commentForm, 'location', HTMLSelectElement); |
| 22 | +const usernameField = namedItem(commentForm, 'username') |
| 23 | +const nameField = namedItem(commentForm, 'name', HTMLInputElement) |
| 24 | +const emailField = namedItem<HTMLInputElement>(commentForm, 'email', HTMLInputElement) |
| 25 | +const mailinglistsField = namedItem<RadioNodeList>(commentForm, 'mailinglists', RadioNodeList) |
| 26 | +const locationField = namedItem<HTMLSelectElement>(commentForm, 'location', HTMLSelectElement) |
27 | 27 |
|
28 | 28 | // Test that default types are indeed inferred properly
|
29 |
| -const typedBody1: HTMLElement = bodyElement1; |
30 |
| -const typedBody2: HTMLBodyElement = bodyElement2; |
31 |
| -const typedFormElements2: Array<HTMLFormElement> = formElements2; |
32 |
| -const typedHtmlElement1: HTMLElement = htmlElement1; |
33 |
| -const typedHtmlElement2: HTMLHtmlElement = htmlElement2; |
34 |
| -const typeUsernameField: HTMLInputElement = usernameField; |
35 |
| -const typedNameField: HTMLInputElement = nameField; |
| 29 | +const typedBody1: HTMLElement = bodyElement1 |
| 30 | +const typedBody2: HTMLBodyElement = bodyElement2 |
| 31 | +const typedFormElements2: Array<HTMLFormElement> = formElements2 |
| 32 | +const typedHtmlElement1: HTMLElement = htmlElement1 |
| 33 | +const typedHtmlElement2: HTMLHtmlElement = htmlElement2 |
| 34 | +const typeUsernameField: HTMLInputElement = usernameField |
| 35 | +const typedNameField: HTMLInputElement = nameField |
0 commit comments