mdx-js / mdx-analyzer

MDX extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=unifiedjs.vscode-mdx
MIT License
331 stars 19 forks source link

[typescript-plugin] Doesn't understand component map #467

Open aaronadamsCA opened 3 weeks ago

aaronadamsCA commented 3 weeks ago

Initial checklist

Affected packages and versions

MDX extension v1.8.9

Link to runnable example

https://codesandbox.io/p/github/aaronadamsCA/mdx-issues/main?file=/src/mdx.mdx

Steps to reproduce

You'll have to run the reproduction in an environment that supports Visual Studio Code extensions.

The TypeScript plugin doesn't seem to understand a component map in a .mdx file:

image

Expected behavior

No errors or warnings.

Actual behavior

The plugin isn't recognizing the destructured Component and the JSX <Component /> as the same object, whereas the actual MDX parser has no problem with this syntax.

Runtime

No response

Package manager

No response

OS

No response

Build and bundle tools

No response

remcohaszing commented 3 weeks ago

I see why this happens and have a rough idea how to fix it. It has to do with the scope analysis of virtual files in https://github.com/mdx-js/mdx-analyzer/blob/main/packages/language-service/lib/virtual-code.js. We will probably need to utilize the more detailed scopes returned by periscopic instead of only relying on the global scope. I will get to it when I get to it, but someone else can give it a try if they want.

The related tests are in https://github.com/mdx-js/mdx-analyzer/blob/vscode-mdx%401.8.9/packages/language-service/test/language-plugin.js.

github-actions[bot] commented 3 weeks ago

Hi! This was marked as ready to be worked on! Note that while this is ready to be worked on, nothing is said about priority: it may take a while for this to be solved.

Is this something you can and want to work on?

Team: please use the area/* (to describe the scope of the change), platform/* (if this is related to a specific one), and semver/* and type/* labels to annotate this. If this is first-timers friendly, add good first issue and if this could use help, add help wanted.