@types/styled-components package and had problems.Definitions by: in index.d.ts) so they can respond.I have a dependency that installs hoist-non-react-statics@2 which causes errors for the definitions in @types/styled-components when using v4.4.1 or higher. This issue can be replicated by manually installing an older version: npm i hoist-non-react-statics@2.
My current solution is to add @types/hoist-non-react-statics@3 to my own package so that @types/styled-components imports the correct version. Perhaps the dependency for @types/hoist-non-react-statics should be "^3.0.0" instead of "*"?
Thank you @marwankhalili , it seems that I have the same issue, whenever I use styled-components styled method I loose any typings on my components, as I am migrating an app to typescript it is really frustrating.
I also have several packages that use hoist-non-react-statics@2 and adding a newer version of @types/hoist-non-react-statics didn't fix the issue.
Any help would be appreciated !
@gorazu Hey, I noticed that only adding the type declarations would not always fix the issue. Try also adding the package itself npm i --save-dev hoist-non-react-statics@3
It worked when installing the package and the types, thank you very much @marwankhalili !
Most helpful comment
@gorazu Hey, I noticed that only adding the type declarations would not always fix the issue. Try also adding the package itself
npm i --save-dev hoist-non-react-statics@3