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
Types for built-in elements getting overriden #228
Comments
The module loads global type definitions, some of the React type definitions. There are other people having this problem, seems there is no good solution to this yet, but workarounds exist There is a possible workaround, maybe you can try that yourself. We might also add that workaround to the repo if it's doable. |
Thanks for the heads up @dummdidumm. That worked! For reference:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"react": ["sink.d.ts"]
}
}
}
declare module 'react'; Is that something that could be added to the language server itself or would it mess things up for a user that actually wanted to use React's types on their project? |
I don't think so. Even if he does, the language server only runs on svelte files, so if he is in a tsx/jsx file, everything should work. I'll add something. |
Reroute react paths to a sink with no typings to prevent conflicts between the svelte2tsx JSX typings and react's JSX typings. This may happen if a node module has (in)directly installed/imported react's types. sveltejs#228
Reroute react paths to a sink with no typings to prevent conflicts between the svelte2tsx JSX typings and react's JSX typings. This may happen if a node module has (in)directly installed/imported react's types. #228
You can test this on nightly build. |
Is it already deployed to the nightly build? It doesn't seem to work unfortunately. However, I think |
Oh, never mind. Seems that changes haven't been deployed to the nightly build yet. I'll test it again tomorrow. |
Thanks for pointing that out, there was an error in the deploy pipeline (order was messed up, so the extension was built with the npm packages from the day before). |
Sorry for the slow response @dummdidumm. I tested the fix and unfortunately it doesn't work, but I played around and found the necessary fixes:
|
I'm not sure about needing |
Thanks for pointing out the Note about |
Thanks for the follow up @dummdidumm! I tested it once again and can confirm for certain that the fix doesn't work if If you tested the current solution and got it to work, check that there's no |
sveltejs#228 Cannot be fixed in the language-server because it would require us to add a baseUrl to the tsconfig.json, which would break every bundler setup which does not know about this.
* (docs) add troubleshooting about conflicting react types #228 Cannot be fixed in the language-server because it would require us to add a baseUrl to the tsconfig.json, which would break every bundler setup which does not know about this. * add note about workaround Co-authored-by: Joel Mukuthu <joelmukuthu@gmail.com> * add image * typo
Docs are added. I will leave this open for now so it's easier to discover in case someone gets the error but does not read the troubleshooting section. |
Great news, this was fixed as a side effect of #351, after the next production release, the workaround with sinks is no longer necessary. |
Wonderful! Thanks for the heads-up! 🎉 |
Describe the bug
If one installs some
@types/*
npm module that somehow overrides React types then type-checking gets messed up. I can imagine why this happens, but it would be nice if it could be fixed somehow. In my case, I'm using storybook (with Svelte) but it installs a bunch of@types/*
modules which somehow mess up the types that the language server users. I haven't identified which of the types modules is the culprit. But ideally the language server types should trump other types.To Reproduce
Steps to reproduce the behavior:
Example code that triggers the error:
Expected behavior
That the HTML would not trigger an error.
Screenshots
System (please complete the following information):
svelte-language-server
,svelte-check
Additional context
svelte-check
also triggers the same errors that show up in the IDE.The text was updated successfully, but these errors were encountered: