Skip to content

Commit

Permalink
Change types to work w/o explicit type parameter
Browse files Browse the repository at this point in the history
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`.
  • Loading branch information
wooorm committed Jul 4, 2023
1 parent cf2dacf commit dc59467
Show file tree
Hide file tree
Showing 8 changed files with 562 additions and 644 deletions.
19 changes: 2 additions & 17 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,7 @@
/**
* @typedef {import('./lib/index.js').Check} Check
* @typedef {import('./lib/index.js').Test} Test
* @typedef {import('./lib/index.js').TestFunctionAnything} TestFunctionAnything
* @typedef {import('./lib/index.js').AssertAnything} AssertAnything
*/

/**
* @template {import('unist').Node} Kind
* @typedef {import('./lib/index.js').PredicateTest<Kind>} PredicateTest
*/

/**
* @template {import('unist').Node} Kind
* @typedef {import('./lib/index.js').TestFunctionPredicate<Kind>} TestFunctionPredicate
*/

/**
* @template {import('unist').Node} Kind
* @typedef {import('./lib/index.js').AssertPredicate<Kind>} AssertPredicate
* @typedef {import('./lib/index.js').TestFunction} TestFunction
*/

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

0 comments on commit dc59467

Please sign in to comment.