question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Typescript Error: Variable StyledComponentClass from external module cannot be named.

See original GitHub issue

Version

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:closed
  • Created 6 years ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
Igorbekcommented, Jul 9, 2017

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.

0reactions
trusktrcommented, Dec 21, 2019

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found