Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,20 @@ visit(sampleTree, 'definition', function (node) {
})
})

visit(sampleTree, ['definition'], function (node) {
visit(node, function (node, _, parent) {
expectNotType<Definition>(node)
expectNotType<never>(parent)
})
})

visit(sampleTree, ['definition'] as const, function (node) {
visit(node, function (node, _, parent) {
expectType<Definition>(node)
expectType<never>(parent)
})
})

function isHeading(node: Node): node is Heading {
return node ? node.type === 'heading' : false
}
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@

/**
* @typedef {(
* Check extends Array<any>
* ? MatchesOne<Value, Check[keyof Check]>
* Check extends ReadonlyArray<any>
* ? MatchesOne<Value, Check[number]>
* : MatchesOne<Value, Check>
* )} Matches
* Check whether a node matches a check in the type system.
Expand Down