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

オープン
#3,187 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
javascript, typescript
領域
tooling

調査の方向性

リンクされた TypeScript Playground で JavaScript の例を再現し、リンクされた再現リポジトリおよびローカルの VS Code の結果と比較してください。Playground がインポートされた宣言型と callback の推論をどのように処理するかを調査してください。callback パラメーターが any ではなく mdast.Image として報告されれば完了です。

索引モデルが issue の本文から書いたものです。

説明

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

主要言語
TypeScript
スター
2.6k
フォーク
1.5k
平均マージ
1日 12時間
マージ済み PR(30日)
5

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

microsoft/TypeScript-Website のほかの issue

microsoft/TypeScript-Website の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。