Skip to content

test type infer is wrong when test is a const array #39

Closed

Description

@JounQin

Initial checklist

Affected package

unist-util-visit@5.0.0

Steps to reproduce

Like syntax-tree/unist-util-visit-parents#17

import { Root } from 'mdast'

import { visit } from 'unist-util-visit'

export default function plugin() {
  return function (tree: Root) {
    visit(tree, ['link', 'linkReference'] as const, node => {
      console.log(node)
      //          ^?
    });
  };
}

TypeScript Playground

Actual behavior

Image

Expected behavior

node should be Link | LinkReference

Runtime

No response

Package manager

No response

Operating system

No response

Build and bundle tools

No response

Activity

  1. added
    👋 phase/newPost is being triaged automatically
    🤞 phase/openPost is being triaged manually
    and removed
    👋 phase/newPost is being triaged automatically
    on Oct 20, 2025
  2. github-actions commented on Dec 15, 2025

    @github-actions
  3. charliez0 commented on Jan 20, 2026

    @charliez0

    @wooorm Can you release a new version covering this fix, thanks!

  4. wooorm commented on Jan 22, 2026

    @wooorm
    Member
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions