Skip to content

Commit 49b4ce8

Browse files
committed
Add Test type
1 parent 44a1891 commit 49b4ce8

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* @typedef {import('hast').Element} Element
55
*
66
* @typedef {string} TagName
7+
* @typedef {null|undefined|TagName|TestFunctionAnything|Array.<TagName|TestFunctionAnything>} Test
78
*/
89

910
/**
@@ -56,7 +57,7 @@ export const isElement =
5657
*
5758
* @type {(
5859
* (<T extends Element>(node: unknown, test: T['tagName']|TestFunctionPredicate<T>|Array.<T['tagName']|TestFunctionPredicate<T>>, index?: number, parent?: Parent, context?: unknown) => node is T) &
59-
* ((node?: unknown, test?: null|undefined|TagName|TestFunctionAnything|Array.<TagName|TestFunctionAnything>, index?: number, parent?: Parent, context?: unknown) => boolean)
60+
* ((node?: unknown, test?: Test, index?: number, parent?: Parent, context?: unknown) => boolean)
6061
* )}
6162
*/
6263
(
@@ -65,8 +66,7 @@ export const isElement =
6566
* When a `parent` node is known the `index` of node should also be given.
6667
*
6768
* @param {unknown} [node] Node to check
68-
* @param {null|undefined|TagName|TestFunctionAnything|Array.<TagName|TestFunctionAnything>} [test]
69-
* When nullish, checks if `node` is a `Node`.
69+
* @param {Test} [test] When nullish, checks if `node` is a `Node`.
7070
* When `string`, works like passing `function (node) {return node.type === test}`.
7171
* When `function` checks if function passed the node is true.
7272
* When `array`, checks any one of the subtests pass.
@@ -117,13 +117,13 @@ export const convertElement =
117117
/**
118118
* @type {(
119119
* (<T extends Element>(test: T['tagName']|TestFunctionPredicate<T>) => AssertPredicate<T>) &
120-
* ((test?: null|undefined|TagName|TestFunctionAnything|Array.<TagName|TestFunctionAnything>) => AssertAnything)
120+
* ((test?: Test) => AssertAnything)
121121
* )}
122122
*/
123123
(
124124
/**
125125
* Generate an assertion from a check.
126-
* @param {null|undefined|TagName|TestFunctionAnything|Array.<TagName|TestFunctionAnything>} [test]
126+
* @param {Test} [test]
127127
* When nullish, checks if `node` is a `Node`.
128128
* When `string`, works like passing `function (node) {return node.type === test}`.
129129
* When `function` checks if function passed the node is true.

0 commit comments

Comments
 (0)