-
-
Notifications
You must be signed in to change notification settings - Fork 10
Closed as not planned
Labels
🤞 phase/openPost is being triaged manuallyPost is being triaged manually
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 discussions and couldn’t find anything (or linked relevant results below)
Affected package
unist-util-select@4.0.3
Steps to reproduce
Given the following 2 files, install typescript@5.9.3, and run tsc to check the types.
// test.ts
import type { Node } from 'unist';
import { select } from 'unist-util-select';
let input: Node;
const myNode = select('my-node', input)Actual behavior
Typescript rejects unist nodes, even though the function is typed to accept them.
Here is the typescript error, verbatim:
$ tsc
test.ts:5:34 - error TS2345: Argument of type 'Node' is not assignable to parameter of type 'Node<Data> | NodeLike'.
Type 'Node' is not assignable to type 'NodeLike'.
Type 'Node' is not assignable to type 'Record<string, unknown>'.
Index signature for type 'string' is missing in type 'Node'.
5 const myNode = select('my-node', input)
~~~~~
Found 1 error in test.ts:5
error: "tsc" exited with code 2Expected behavior
The function should accept any valid unist or unist-like node, including derivatives such as hast and mdast. Curiously, if we replace the "input" variable with u('parent') from unist-builder, typescript is happy.
Runtime
node@v22.17.1
Package manager
npm@11.4.2
Operating system
Fedora Linux 42
Build and bundle tools
No response
Metadata
Metadata
Assignees
Labels
🤞 phase/openPost is being triaged manuallyPost is being triaged manually