texasranger
texasranger8mo ago

jsxImportSourceTypes not working for React

I've tried doing this:
"jsx": "react-jsx",
"jsxImportSource": "react",
"jsxImportSourceTypes": "@types/react"
"jsx": "react-jsx",
"jsxImportSource": "react",
"jsxImportSourceTypes": "@types/react"
(with proper import mapping) but Deno nor VS Code recognize React's types. I've outlined more details here in an issue: https://github.com/denoland/deno/issues/23702
GitHub
Loading React types cripples LSP performance · Issue #23702 · denol...
Version: Deno 1.43.1 I was excited by the snappy performance of the LSP in VS Code for version 1.43 however as soon as you load React's types the 10+ second processing time resumes. This is the...
2 Replies
Deno AI Helper
Deno AI Helper8mo ago
Based on the documentation, the jsxImportSourceTypes compiler option allows you to specify the types for the automatic JSX transform, which is useful with libraries that don’t provide their types. However, it seems like you are encountering an issue where Deno and VS Code are not recognizing React's types even with the correct configuration. Here's an example from the documentation on how to configure jsxImportSourceTypes in your deno.json file:
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "npm:react@^18.3",
"jsxImportSourceTypes": "npm:@types/react@^18.3"
}
}
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "npm:react@^18.3",
"jsxImportSourceTypes": "npm:@types/react@^18.3"
}
}
Make sure that your deno.json configuration matches the structure shown in the documentation, including the npm specifiers with version numbers. If you've already done this and are still facing issues, it could be a bug or a compatibility problem. Since you've already opened an issue on the Deno repository, the best course of action is to wait for a response from the Deno maintainers or contributors who can provide more insight into the problem. They might ask for additional information or provide a workaround or a fix. In the meantime, ensure that you are using the latest version of Deno, as updates often include bug fixes and improvements. You can update Deno by running:
deno upgrade
deno upgrade
Also, double-check that your import mappings are correctly set up and that there are no typos or misconfigurations that could be causing the issue. If you need immediate assistance, consider reaching out on the Deno Discord or checking if there are any similar issues that have been resolved, which might give you a clue on how to fix your problem. 🦕
lcasdev
lcasdev8mo ago
@texasranger have you tried restarting vscode completely after adding the jsxImportSourceTypes option?

Did you find this page helpful?