TypeScript Playground Shows Inconsistent `any` for `unist-util-visit` type
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
- Tech stack
- javascript, typescript
- 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
/**
* @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
})
}
}
- 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from microsoft/TypeScript-Website
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
microsoft/TypeScript-Website#3611 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
microsoft/TypeScript-Website#3607 ·
-
Difficulty 1/5 Under an hour Newbie friendliness 65/100
microsoft/TypeScript-Website#3039 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/TypeScript-Website#2998 ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
microsoft/TypeScript-Website#3614 ·
All issues in microsoft/TypeScript-Website
Similar issues
-
clawsweeper:linked-pr-open clawsweeper:no-new-fix-pr clawsweeper:source-repro impact:message-loss issue-rating: 🦞 diamond lobster maturity:stable P2
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
Eynzof/Hermes-CN-Desktop#616 ·
-
ZCode 3.14.3 に対応する Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
supermomonga/zcode-acp#24 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
growthbook/growthbook#7100 ·
-
triage
Difficulty 1/5 1-3 hours Newbie friendliness 88/100