[TS] StyledComponentClass does not have any construct or call signatures
See original GitHub issueHello. I’m trying to up a new project with typescript + styled-components, but I faced with a problem with prop types + jsx.
I get this error: [ts] JSX element type 'Styled' does not have any construct or call signatures
when I try to use a Component from styled.
type Props = {
color: string,
};
const Styled = styled<Props>('div')`
color: ${p => p.color};
`;
// later
render() {
return (
<Styled /> {/* [ts] JSX element type 'Styled' does not have any construct or call signatures */}
) ;
}
Styled
type is StyledComponentClass<Props, any, Props>
by inference as specified in styled typings.
But if I force the type as any
it works ‘normally’, without error:
const Styled: any = styled<Props>('div')`
color: ${p => p.color};
`;
But this way I’ll loss all the typing benefit, I think.
I tried put StatelessComponent<Props>
instead of any, but unsuccessfully (I don’t know why, I’m new with TS)
How can I get around this situation?
Issue Analytics
- State:
- Created 6 years ago
- Reactions:4
- Comments:5
Top Results From Across the Web
JSX element type Elem does not have any construct or call ...
What you want is a function that takes a constructor for React. ... Type '(props: myProps) => Element' provides no match for the...
Read more >JSX element type does not have any construct or call signatures
The error "JSX element type does not have any construct or call signatures" occurs when we try to pass an element or a...
Read more >jsx element type 'component' does not have any construct or ...
Element" :: "JSX element type 'Component' does not have any construct or call signatures.ts(2604)". Currently, I have been looking to updates for both...
Read more >Advanced Usage - styled-components
In the render tree all styled-components will have access to the provided theme, even when they are multiple levels deep. To illustrate this,...
Read more >JSX element type X does not have any construct or call ...
JSX element type X does not have any construct or call signatures.ts(2604) ... I wanted to make a styled button with Material UI...
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
Sorry, my bad. I forgot to install
@types/react
;After much playing about I noticed that you have to enable Typescript support on VSCode. I had a fresh install of VSCode and after installing/enabling full support the Typingscript it worked.
Just click Typescript on the welcome screen and reload your editor. It’s funny cause Typescript syntax works out the box for VSCode, but only after I do this does it begin to work 🤔
Thanks again team.
❤️💅