-
Notifications
You must be signed in to change notification settings - Fork 5.4k
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
JSX element implicitly has type 'any' because no interface 'JSX.IntrinsicElements' exists. When using Preact v10.16.0 #20582
Comments
Can you check that the deno vscode plugin is initialized? There is a command for that in the vscode command palette. |
Yep it is, in fact this is a project I'm currently running. Changing it to Preact v10.15.1 works good. That's my workaround for now. |
Screencast.from.2023-07-18.14-03-35.webm |
Solutions
deno task start and reload browser window (deno automatically cache missing dependencies) |
I use all latest preact / twind and it's work fine |
Really weird @afifurrohman-id. I followed the steps you provided + I added --reload in my task to renew cache but still is showing that warning. |
Alright I think I figured out the issue, but the workaround is a little odd to me: To replicate the issue:
You should see something like this:
Now you should be able to see the error above:
My question is, why using |
@sant123 this worked for me. Idk why |
FWIW For people commenting here: It's not an issue with Fresh but with Deno's LSP. We are aware of the issue but haven't found the root cause yet nor a reliable way to reproduce it. Sometimes I can reproduce it and when I try again it doesn't work anymore. The steps listed earlier in the thread don't work for me to reproduce it. My guess as to why |
I'll transfer this upstream to the deno cli repository, since this is not an issue with Fresh. |
for me restarting the LSP / vscode didn't do it, but running |
Follow documentation at https://docs.deno.com/runtime/manual/advanced/jsx_dom/jsx. There are multiple options, the least intrusive seems to be having deno.jsonc with this:
|
In my case, I have a core program, and from that I have auxiliary components¹: test, web app, cli app. Initially I worked on the core + cli app + test, then recently I work on the web app with Fresh. At first I separated the project to learn the framework easier. Then I joined them together so that I could debug the core easier. My code works fine when it's in a separate project; all I do is to copy it to the bigger one. Now every component has this problem:
Reload VS Code doesn't help. It turns out that VS Code can recognize the "compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
},
"imports": {
"preact/": "https://esm.sh/[email protected]/"
} |
…y `preact` was not being resolved in a monorepo setup This is done to fix linting errors(see denoland/deno#20582 (comment))
* wip(templates/crm): updates and improvements * chore(deno): use absolute URL `jsxImportSource` since import map entry `preact` was not being resolved in a monorepo setup This is done to fix linting errors(see denoland/deno#20582 (comment)) * wip(templates/crm): updates and improvements * chore(deno): add react types and use react as `jsxImportSource` (for root `deno.jsonc` only) This fixes deno LSP issues with react-based `netzo/components`. * chore: format codebase * chore: format codebase * chore(templates/crm): updates and improvements * fix(deno): remove `compilerOptions.types` option which was freezing dev and build tasks * wip(templates/crm): updates and improvements * wip(deno): attempt to fix broken test "Could not find constraint '[email protected]' in the list of packages." * chore(templates/crm): fix broken test
|
@adamzerner There was a regression that was fixed recently, try with |
@nayeemrmn Looks like that did the trick. Thanks. |
I am not sure why, but this could be because of typescript typings that the following deno config works and fixes the issue present here: {
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "https://esm.sh/[email protected]",
}
} while the following is broken: {
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "react",
"lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"]
},
"nodeModulesDir": "auto",
"imports": {
"react": "npm:react@^18.3.1",
"react-dom": "npm:react-dom@^18.3.1"
}
} |
@phoenisx The types for {
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "react",
"jsxImportSourceTypes": "@types/react",
"lib": ["dom", "dom.iterable", "dom.asynciterable", "deno.ns"]
},
"nodeModulesDir": "auto",
"imports": {
"react": "npm:react@^18.3.1",
"react-dom": "npm:react-dom@^18.3.1",
"@types/react": "npm:@types/react@^18.3.11"
}
} https://docs.deno.com/runtime/reference/jsx/#jsximportsourcetypes |
@nayeemrmn do you know if there is a way for a module set a certain // @deno-types="@types/react"
import { version } from "react";
// @deno-types="npm:@types/react-dom@^18.3.1/server"
import { renderToStaticMarkup } from "react-dom/server";
const html = renderToStaticMarkup(<h1>Hello world!</h1>);
console.log(html, version); It would be nice to not type |
Just found what I mentioned #25633 |
This is my deno.json
Thanks!
The text was updated successfully, but these errors were encountered: