-
-
Notifications
You must be signed in to change notification settings - Fork 32.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
TS typings are not working for styled components #13167
Comments
Hmmm ... maybe it's actually not an issue, removing the type cast from I'm testing this just now. |
You are not following the guide closely. The generic argument for the returntype of |
@eps1lon is this documented in the official docs? Because what's in typescript doesn't really work for me. Well, the VSC autocomplete does not pickup on the props that I have declared, but ts-loader seems to not care. So when using the component that's styled somewhere: <div>
<MyComp open={true} />
</div> The I've removed the type invocation as the PR pointed out, but that did not change the behaviour I'm describing. |
I wonder if this could be related to workspaces, as the other project where I experience this, is actually a monorepo with a couple apps. |
"doesn't really work for me" is not something I can debug. You repro still has I cloned your repro and after the applied fix VSCode has no issues suggesting props via autocomplete.
|
@eps1lon sorry, I know that cannot be reproduced 😄 I tried to replicate what I experienced, in my own project, in the repo I referenced, but with little success 😞 That's why I closed the issue previously, because the small example in that repo worked just fine after I removed the type cast. I'll give it another try to see what's different between the small example and my project setup and if I cannot find anything I will just close this issue. |
@rolandjitsu Did anything ever come of this? I am experiencing the exact same issue that you are describing. Keeping the cast on withStyles will break the compiler. taking the cast off withStyles prevents any autocomplete and type safety that TypeScript is supposed to give you. I did reference this post, which seems to describe breaking change but I am struggling to find the correct syntax that will give me type safety and not break compilation. for example, what does this become?
|
After I have updated to the latest version of the lib (
3.2.0
), I cannot build my apps anymore withreact-scripts-ts
due to some typings errors with styled components.Expected Behavior
I should be able to build a component that is styled:
Current Behavior
It fails during compilation with:
Steps to Reproduce
Link: https://github.com/rolandjitsu/mui-ts-sfc
yarn install
at rootyarn start
Context
I'm building some react app using TS with react-scripts-ts and I'm trying to style a component according to docs.
Your Environment
The text was updated successfully, but these errors were encountered: