Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Discussion options

Hi there 👋

I have been updating my dependencies and now tsc is complaining about unist-util-visit.

Given the following:

import { Image, Root } from 'mdast';
import { visit } from 'unist-util-visit';

export function inlineImages() {
  return async (tree: Root) => {
    const nodes: Image[] = [];

    visit(tree, 'image', (node) => {
      nodes.push(node);
    });

    // ...
  };
}

It seems I'm now not allowed to pass a Root type as 1st argument to visit:

Screenshot 2024-07-24 at 14 59 19

However I'm unsure how to type the suggested Node<Data>. I've tried Node from mdast and unist but to no avail.

Any help greatly appreciated 😎

You must be logged in to vote

Hey @dmca-glasgow 👋
That error looks a lot like you may be mixing major versions of unist-util-visit and @types/mdast.
Make sure are both on the latest major version, at the time of writing these are @types/mdast v4 and unist-util-visit v5.

https://stackblitz.com/edit/github-4yca6z?file=src%2Fmain.ts

Replies: 1 comment · 1 reply

Comment options

Hey @dmca-glasgow 👋
That error looks a lot like you may be mixing major versions of unist-util-visit and @types/mdast.
Make sure are both on the latest major version, at the time of writing these are @types/mdast v4 and unist-util-visit v5.

https://stackblitz.com/edit/github-4yca6z?file=src%2Fmain.ts

You must be logged in to vote
1 reply
@dmca-glasgow
Comment options

Many thanks @ChristianMurphy

Answer selected by dmca-glasgow
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
🙏
Q&A
Labels
☂️ area/types This affects typings
2 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.