-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
My IDE report Error Its type '"p"' is not a valid JSX element type.
#3984
Comments
Have you restarted the TS language server? What does your |
Here is my
|
Remove I have to imagine it's just a temporary bug in your editor, as everything else it looks fine. Give your editor a restart it you haven't already, or try to reproduce the issue in something like codesandbox if it persists. |
It is no work of removing |
You can try adding Otherwise not sure; not a VSCode user myself and it seems like it might be some misconfiguration in your editor specifically. |
Thank you very much for your patient reply. I have tried all the methods mentioned in the document, but none of them have worked. I will use comments |
Can you share a small repo or codesandbox where the issue can be reproduced? That will make it much easier to narrow it down. |
I have the same problem of VSCode saying "'div' cannot be used as a JSX component.". Here is a repo from which I reproduce the error message, it is a minimal preact x typescript configured following preact docs : https://github.com/lm-maxfab/preact-test No problem at build time though, the compilation via esbuild goes well and the built output works. |
Here is my minimal repository with the same problem: https://github.com/davidmz/preact-types-test |
I'm a bit surprised to see 3 (seemingly unrelated) people have the same issue. Is this specifically an issue with the latest or recent versions of Preact? Do you still see this if you go back a bit (say, mid v10)? |
@lm-maxfab Thanks for sharing that repo. Weirdly I'm unable to reproduce that on my end. VSCode finds the correct JSX types. Works in both the stable release line and vscode insiders for me. Note that @davidmz I'm getting a 404 on that link. Is the repo private? |
@marvinhagemeister oh, sorry, it really was private. I've now made it public. But now I see the same error with clean |
Well, my VSCode had the ms-vscode.vscode-typescript-next extension installed. I disabled it, and that seemed to fix the problem, at least for me. Sorry, I didn't check that at first. |
Interesting, maybe should raise this on that extension's tracker. @lm-maxfab and @XLearner, do you have this installed too by chance? |
I see there is a recent bug in Typescript that looks similar: microsoft/TypeScript#53939. Maybe the extension was using the nightly version with this bug. |
Yep, had it installed too, everything's fine when disabling it. Thanks a lot! |
Wow, that's really the key to the problem. After reloading this plugin, there is no issue anymore. Thank you very much! |
Closing this as it seems to be a genuine TS related bug, for anyone finding this thread, disabling |
I imported preact into my project and the project worked successfully. However, the VSCode had always the following error message:
I can use
// @ts-expect-error
to shield this error, but I want to get a more gentle way to deal with this.Could anyone help? 🤜🏽
The text was updated successfully, but these errors were encountered: