Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use jsxImportSource types if available #490

Closed
4 tasks done
souporserious opened this issue Jan 2, 2025 · 7 comments
Closed
4 tasks done

use jsxImportSource types if available #490

souporserious opened this issue Jan 2, 2025 · 7 comments
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on

Comments

@souporserious
Copy link

souporserious commented Jan 2, 2025

Initial checklist

Affected package

vscode-mdx

Steps to reproduce

  • Use a library that makes use of jsxImportSource, like restyle.
  • Once jsxImportSource is configured, add an MDX file that has an element with the css prop e.g. <div css={{ color: 'tomato' }} />
  • The VS Code extension will not recognize the types and will error when trying to use the css prop.

Actual behavior

When using the css prop from restyle in this case, it will error incorrectly. The functionality works as expected, but there is a type error because the extension doesn't recognize the css element prop is ok:

image

Expected behavior

Similar to how ts/tsx files will pick up the types if jsxImportSource is configured, it would be great if the VS Code extension could load the related types as well.

Runtime

No response

Package manager

No response

Operating system

No response

Build and bundle tools

No response

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jan 2, 2025
@souporserious souporserious changed the title jsxImportSource types should be respected use jsxImportSource types if available Jan 2, 2025
@remcohaszing
Copy link
Member

It respects TypeScript’s jsxImportSource in tsconfig.json. Are you seeing something else? If so, please provide a reproduction.

@remcohaszing remcohaszing added the 🙊 open/needs-repro This needs a reproduction label Jan 2, 2025

This comment has been minimized.

@souporserious
Copy link
Author

Interesting, yeah it doesn't seem to get recognized for me, at least in a Next.js repo with MDX and jsxImportSource configured. I made a minimal reproduction here. I'm using v1.8.13 of the MDX VS Code extension and Node v21.2.0.

@remcohaszing
Copy link
Member

That project excludes MDX files from the TypeScript program by specifying an include pattern that doesn’t include MDX. As a result, MDX files are part of the default TypeScript program created by the language server. This defaults to the jsxImportSource value react.

The best thing to do here is to remove the include and exclude options from tsconfig.json. However I am aware Next.js will add back these bad defaults.

The alternative solution is to add **/* (preferred) or **/*.mdx to the include array.

@remcohaszing remcohaszing closed this as not planned Won't fix, can't repro, duplicate, stale Jan 2, 2025

This comment has been minimized.

@remcohaszing remcohaszing added 🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on and removed 🙊 open/needs-repro This needs a reproduction labels Jan 2, 2025
@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Jan 2, 2025
Copy link
Contributor

github-actions bot commented Jan 2, 2025

Hi! Thanks for reaching out! Because we treat issues as our backlog, we close issues that are questions since they don’t represent a task to be completed.

See our support docs for how and where to ask questions.

Thanks,
— bb

@souporserious
Copy link
Author

I see, apologies for filing an issue, didn't realize it was using a different configuration 😅. Thank you for the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🙋 no/question This does not need any changes 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

2 participants