-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
index.test-d.ts
43 lines (37 loc) · 1.25 KB
/
index.test-d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import {expectType} from 'tsd';
import {$, $$, elementExists, lastElement, expectElement} from './index.js';
// `select-dom` defaults to HTMLElement where possible because it's the most common use case, even if technically this should not be HTMLElement.
/**
* SELECT
*/
expectType<HTMLElement | undefined>($('.wow'));
expectType<HTMLAnchorElement | undefined>($('a.wow'));
expectType<HTMLBaseElement | undefined>($('base'));
expectType<SVGGElement | undefined>($('g'));
/**
* EXPECT
*/
expectType<HTMLElement>(expectElement('.wow'));
expectType<HTMLAnchorElement>(expectElement('a.wow'));
expectType<HTMLBaseElement>(expectElement('base'));
expectType<SVGGElement>(expectElement('g'));
/**
* LAST
*/
expectType<HTMLElement | undefined>(lastElement('.wow'));
expectType<HTMLAnchorElement | undefined>(lastElement('a.wow'));
expectType<HTMLBaseElement | undefined>(lastElement('base'));
expectType<SVGGElement | undefined>(lastElement('g'));
/**
* EXISTS
*/
expectType<boolean>(elementExists('.wow'));
expectType<boolean>(elementExists('base'));
expectType<boolean>(elementExists('g'));
/**
* ALL
*/
expectType<HTMLElement[]>($$('.wow'));
expectType<HTMLBaseElement[]>($$('base'));
expectType<SVGGElement[]>($$('g'));
expectType<HTMLAnchorElement[]>($$('a.wow'));