Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

TypeScript Playground Shows Inconsistent `any` for `unist-util-visit` type

Open
#3,187 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Domain
tooling

Research direction

Reproduce the JavaScript example in the linked TypeScript Playground and compare it with the linked reproduction repository and local VS Code result. Investigate how the Playground handles the imported declaration types and callback inference; done means the callback parameter is reported as mdast.Image rather than any.

Written by the indexing model from the issue text.

Description

First of all, thanks so much for the TypeScript Playground and all other TS tooling, amazing effect on robustness of JS code 🙌

In this issue comment in unist-util-visit, I discovered some inconsistent behavior in the TypeScript Playground:

Actual

In the TypeScript Playground, the type of node in the callback passed to unist-util-visit is any

Playground

/**
 * @import {Root} from 'mdast'
 */

import { visit } from "unist-util-visit";

// TS Playground only: Import `@types/mdast` for JSDoc type imports
import 'mdast';

export function myPlugin() {
  /**
   * @param {Root} tree
   * @returns {undefined}
   */
  return function (tree) {
    visit(tree, 'image', function (node) {
                                // ^? any
    })
  }
}

Expected

...where it is mdast.Image in a local VS Code:

Reproduction repo: https://github.com/karlhorky/repro-unist-util-visit-node-any

/**
 * @import {Root} from 'mdast'
 */

import { visit } from "unist-util-visit";

export function myPlugin() {
  /**
   * @param {Root} tree
   * @returns {undefined}
   */
  return function (tree) {
    visit(tree, 'image', function (node) {
                                // ^? mdast.Image
    })
  }
}

Screenshot 2024-07-22 at 11 13 14

Dominant language
TypeScript
Stars
2.6k
Forks
1.5k
Avg merge
2d 12h
Merged PRs (30d)
8

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from microsoft/TypeScript-Website

All issues in microsoft/TypeScript-Website

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.