Skip to content

[unist-util-filter] Typescript: Property 'type' does not exist on type 'Test<Node>' #29

Answered by ChristianMurphy
bearcanrun asked this question in Q&A
Discussion options

You must be logged in to vote

A few different questions in here: 1 what is the input to a Test accept? 2 why is type missing? 3 what is a way to resolve this?

  1. what is the input to a Test accept?

    (node: Test<YamlNode>): node is YamlNode => node.type !== 'yaml'

    is known as a Test https://github.com/syntax-tree/unist-util-is#function-testnode-index-parent. A test may or may not receive a valid node, as such it doesn't know what it's receiving and node is type unknown.
    a Test can also be null which checks that a node is valid (but not it's type), string which check that a node is valid and that node type matches the string passed in, or an object which checks that it matches passed in attributes.
    https://github.com/synt…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@bearcanrun
Comment options

Answer selected by bearcanrun
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants