-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
NPM types: TSX warnings about JSX.IntrinsicElements in React #16653
Comments
It is planned, but currently no ETA. Have you tried adding |
Yeah, that wouldn't work because there's no import to set that on. One way to set the JSX globals is to do:
...or do...
But then I get the error:
...which only occurs in the LSP... not sure why. I think that's because |
Bartek's latest commit (300fd07) resolves that issue I was seeing in my last comment (it was incorrectly resolving npm:react to the js file for type checking). Adding a tiple slash directive reference or |
@dsherret I'm also getting the below error on all my imports which causes types to fail altogether. thanks for your work on this! 👍 |
I resolved temporarily this by using |
This is my workaround for server side rendering. Hope it helps: // @deno-types="npm:@types/react"
import React from "npm:react";
// @deno-types="npm:@types/react-dom/server"
import ReactDOM from "npm:react-dom/server";
function App() {
return <h1>Hello world!</h1>;
}
console.log(ReactDOM.renderToString(<App />)); |
|
@jimisaacs maybe related #17012 -- this was just fixed and a test was added yesterday to prevent regressions. It seems to work in canary ( |
@dsherret Nice! Good to know it seems to be addressed. Though unfortunately it's a little difficult to try because of the following I was hoping to see if all this was related, i.e. if the same issue was causing the following error with
|
That's too bad. I wish we had canary builds with M1. We need an M1 CI to do that, but github doesn't have them yet. Yeah, you can bypass that error by skipping type checking with |
🙇 |
@dsherret @jimisaacs just tested with canary and looks good!! |
This will also work: import type {} from "npm:@types/react"
import type {} from "npm:@types/react-dom" The LSP will correctly pickup the types |
Ref #20455 |
I have a TSX project with the following
deno.json
configuration:In VS Code I see the following warning:
This doesn't happen if the JSX import source is preact (
npm:preact
).I think the reason is because the preact NPM package includes the types (https://github.com/preactjs/preact/blob/master/src/index.d.ts) so Deno can load them.
React needs to fetch the types from
@types/react
and this is not implemented in Deno. In the NPM roadmap (#15960) I can see the uncompleted taskautomatic acquisition of @types package for type checking
.Is there any plans to implement this at anytime soon? I think it should be quite useful. At this moment, the only way to use React in Deno without TSX errors is by importing from esm.sh.
The text was updated successfully, but these errors were encountered: