Typescript Error: Variable StyledComponentClass from external module cannot be named.
See original GitHub issueVersion
2.1.1 Typescript version 2.3.3
Reproduction
I created styled-components variable
const Wrapper = styled.header`
background-color: red;
height: 50px;
width: 100%;
`
Until here It’s still OK. But, it will throw error if I export Wrapper
.
export const Wrapper = styled.header`
▾▾▾▾▾▾▾
[ts] Exported variable 'Wrapper' has or is using name 'StyledComponentClass' from external module "/path/project/node_modules/styled-components/typings/styled-components" but cannot be named.
const Wrapper: StyledComponentClass<React.HTMLProps<HTMLElement>, any, React.HTMLProps<HTMLElement>>
background-color: red;
height: 50px;
width: 100%;
`
Steps to reproduce
Expected Behavior
It’s not throw type error
Actual Behavior
Throw error
[ts] Exported variable ‘Wrapper’ has or is using name ‘StyledComponentClass’ from external module “/path/project/node_modules/styled-components/typings/styled-components” but cannot be named. const Wrapper: StyledComponentClass<React.HTMLProps<HTMLElement>, any, React.HTMLProps<HTMLElement>>
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (4 by maintainers)
Top Results From Across the Web
Typescript 2.4 Error: Variable StyledComponentClass ... - GitHub
The following error occurs: [ts] Exported variable 'Wrapper' has or is using name 'StyledComponentClass' from external module "/path/project/ ...
Read more >Typescript error using styled-components - Stack Overflow
[ts] Exported variable 'Title' has or is using name 'StyledComponentClass' from external module "/blah/blah/node_modules/styled-components/ ...
Read more >Kent C. Dodds on Twitter: "@pelotom I did see that same ...
Hey TypeScript friends I have a use case where a type I'm making needs to be a combination of a type from another...
Read more >False typescript error : WEB-42042 - YouTrack
The error is: TS4023: Exported variable 'selectedPrinterSelector' has or is using name 'Pages' from external module "[...]/UI" but cannot be named.
Read more >Getting "Exported variable 'X' has or is using name 'Y' from ...
Getting "Exported variable 'X' has or is using name 'Y' from external module 'a/file/path' but cannot be named".
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, good to hear that it works now. There could be many reasons why it was not working, like conflicting typescript versions, incomplete modules set up and so on, I think if it is not reproducible anymore, we are good.
I’ve opened a request to fix issues like these in TypeScript by bringing declaration files to parity with language features. https://github.com/microsoft/TypeScript/issues/35822