Skip to content

[Type]: parent type is missing #38

@NullVoxPopuli

Description

@NullVoxPopuli

Initial checklist

Affected package

unist-util-visit

Steps to reproduce

use typescript, have a simple plugin:

import type { Pluggable } from 'unified'
import { visit } from 'unist-util-visit';

const removePre: Pluggable = (/* options */) => {
  return function transformer(tree) {
    visit(tree, ['code'], function (node, index, parent) {
                                              // ^ type: any
      if (!parent) return;
      if (undefined === index) return;

      parent.children[index] = {
   // ^ type: never

parent should be Parent | undefined as reported by:

but somewhere alone the line the fix was lost.

Actual behavior

type is incorrect

Expected behavior

type is correct

Runtime

No response

Package manager

No response

Operating system

No response

Build and bundle tools

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    👎 phase/noPost cannot or will not be acted on🙋 no/questionThis does not need any changes

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions