Skip to content

Commit 374dd25

Browse files
committed
Add Test type
1 parent 2f3214b commit 374dd25

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

index.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*
55
* @typedef {string} Type
66
* @typedef {Object<string, unknown>} Props
7+
*
8+
* @typedef {null|undefined|Type|Props|TestFunctionAnything|Array.<Type|Props|TestFunctionAnything>} Test
79
*/
810

911
/**
@@ -53,7 +55,7 @@ export var is =
5355
*
5456
* @type {(
5557
* (<T extends Node>(node: unknown, test: T['type']|Partial<T>|TestFunctionPredicate<T>|Array.<T['type']|Partial<T>|TestFunctionPredicate<T>>, index?: number, parent?: Parent, context?: unknown) => node is T) &
56-
* ((node?: unknown, test?: null|undefined|Type|Props|TestFunctionAnything|Array.<Type|Props|TestFunctionAnything>, index?: number, parent?: Parent, context?: unknown) => boolean)
58+
* ((node?: unknown, test?: Test, index?: number, parent?: Parent, context?: unknown) => boolean)
5759
* )}
5860
*/
5961
(
@@ -62,7 +64,7 @@ export var is =
6264
* When a `parent` node is known the `index` of node should also be given.
6365
*
6466
* @param {unknown} [node] Node to check
65-
* @param {null|undefined|Type|Props|TestFunctionAnything|Array.<Type|Props|TestFunctionAnything>} [test]
67+
* @param {Test} [test]
6668
* When nullish, checks if `node` is a `Node`.
6769
* When `string`, works like passing `function (node) {return node.type === test}`.
6870
* When `function` checks if function passed the node is true.
@@ -113,13 +115,13 @@ export var convert =
113115
/**
114116
* @type {(
115117
* (<T extends Node>(test: T['type']|Partial<T>|TestFunctionPredicate<T>) => AssertPredicate<T>) &
116-
* ((test?: null|undefined|Type|Props|TestFunctionAnything|Array.<Type|Props|TestFunctionAnything>) => AssertAnything)
118+
* ((test?: Test) => AssertAnything)
117119
* )}
118120
*/
119121
(
120122
/**
121123
* Generate an assertion from a check.
122-
* @param {null|undefined|Type|Props|TestFunctionAnything|Array.<Type|Props|TestFunctionAnything>} [test]
124+
* @param {Test} [test]
123125
* When nullish, checks if `node` is a `Node`.
124126
* When `string`, works like passing `function (node) {return node.type === test}`.
125127
* When `function` checks if function passed the node is true.

0 commit comments

Comments
 (0)