Skip to content
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

[@types/styled-components] Error using styled component in functional component #41790

Closed
4 tasks done
ortonomy opened this issue Jan 22, 2020 · 2 comments
Closed
4 tasks done

Comments

@ortonomy
Copy link

ortonomy commented Jan 22, 2020

Admittedly I've very very new to TS, so I'm just coming to terms with all the syntax and the demands for different definitions of types. However, this seems like something that almost EVERY user of styled-components would like to do, but I can't find reference to this error anywhere.
The first demo of such a use case appears here in their docs: https://styled-components.com/docs/basics#adapting-based-on-props

I've checked the styled-components typescript section and doesn't reference this usage at all: https://styled-components.com/docs/api#using-custom-props

image

'FullScreenDiv' refers to a value, but is being used as a type here.ts(2749)

I've done my searching and the closest I can get is this issue: #39136

But I don't really understand if this is related to generics or something else.

@eps1lon
Copy link
Collaborator

eps1lon commented Jan 22, 2020

It looks like you're in a .ts file while using JSX syntax. If you want to use JSX you need to use the .tsx file extension. For more information see https://www.typescriptlang.org/docs/handbook/jsx.html

Either way this issue is not specific to styled-componets. If my suggestion didn't help I would refer you to stackoverflow.com. It would help a lot if you would be so kind and link the created question and close this issue.

@ortonomy
Copy link
Author

@eps1lon -- thanks for the tip. Worked perfectly.

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants