Closed
Description
Initial checklist
- I read the support docs
- I read the contributing guide
- I agree to follow the code of conduct
- I searched issues and couldn’t find anything (or linked relevant results below)
Problem
if (isElement(parent)) {
console.log(parent) // expect `Element` type here
}
Solution
remove https://github.com/syntax-tree/hast-util-is-element/blob/main/index.js#L60
So that it will yield the following typings
/**
* Check if a node is an element and passes a certain node test
*
* @template {Element} Y
* @callback AssertPredicate
* @param {unknown} [node]
* @param {number|null|undefined} [index]
* @param {Parent|null|undefined} [parent]
* @returns {node is Y}
*/
export const isElement: (<T extends import('hast').Element>(
node?: unknown,
test?:
| T['tagName']
| TestFunctionPredicate<T>
| (T['tagName'] | TestFunctionPredicate<T>)[],
index?: number | undefined,
parent?:
| import('unist').Parent<
import('unist').Node<import('unist').Data>,
import('unist').Data
>
| undefined,
context?: unknown
) => node is T)
Alternatives
N/A