Skip to content

Commit dc59467

Browse files
committed
Change types to work w/o explicit type parameter
Previously, the type parameter of the kind of node that was checked for needed to be passed. This node kind had to be matched by the given runtime `test`. At that point, it was known that node would be of that kind. Now, the given runtime test is used in the type system to narrow the given `node` value down. This means that the types can become much simpler. Instead of `AssertAnything` and `AssertPredicate`, use the new `Check`. Instead of `TestFunctionAnything` and `TestFunctionPredicate`, use `TestFunction`. Instead of `PredicateTest`, use `Test`.
1 parent cf2dacf commit dc59467

File tree

8 files changed

+562
-644
lines changed

8 files changed

+562
-644
lines changed

index.js

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
11
/**
2+
* @typedef {import('./lib/index.js').Check} Check
23
* @typedef {import('./lib/index.js').Test} Test
3-
* @typedef {import('./lib/index.js').TestFunctionAnything} TestFunctionAnything
4-
* @typedef {import('./lib/index.js').AssertAnything} AssertAnything
5-
*/
6-
7-
/**
8-
* @template {import('unist').Node} Kind
9-
* @typedef {import('./lib/index.js').PredicateTest<Kind>} PredicateTest
10-
*/
11-
12-
/**
13-
* @template {import('unist').Node} Kind
14-
* @typedef {import('./lib/index.js').TestFunctionPredicate<Kind>} TestFunctionPredicate
15-
*/
16-
17-
/**
18-
* @template {import('unist').Node} Kind
19-
* @typedef {import('./lib/index.js').AssertPredicate<Kind>} AssertPredicate
4+
* @typedef {import('./lib/index.js').TestFunction} TestFunction
205
*/
216

227
export {is, convert} from './lib/index.js'

0 commit comments

Comments
 (0)