jacob-ebey / styled-components-ts

Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress and the added benefits of TypeScript 💅
Do What The F*ck You Want To Public License
150 stars 5 forks source link

No exported member 'StyledComponentClass' #18

Closed elie222 closed 5 years ago

elie222 commented 5 years ago

I get this error when using this package:

project/node_modules/styled-components-ts/lib/styled-components-ts.d.ts
(3,32): Module '"project/node_modules/@types/styled-components/index"' has no exported member 'StyledComponentClass'. Did you mean 'StyledComponentBase'?

Any idea?

    "styled-components": "^4.1.2",
    "styled-components-ts": "^0.0.15"
elie222 commented 5 years ago

I got things working without this package doing something like this:

const Button = styled.div<{ selected?: boolean }>`
  background: ${props => props.selected ? 'red' : 'blue'};
`
jacob-ebey commented 5 years ago

This package should ultimately be useless with the latest version of styled-components and the latest pre-released typescript version.

mrmartineau commented 5 years ago

@elie222 I had no idea that this could be done, thank you. It looks like this package is redundant now. Thanks for creating it @jacob-ebey 👍

jacob-ebey commented 5 years ago

NP, I'm just hoping the styled-components group updates their docs (as I can no longer locate the original issue that sparked this library) or this will never die. There was a fairly long thread on why this wasn't possible before with a link to the typescript fix that allowed a fix.

jacob-ebey commented 5 years ago

Thanks for the docs PR @mrmartineau!

elie222 commented 5 years ago

Their docs are pretty bad btw. I think the two lines of sample code I stuck above actually do a better job of explaining how it's used.

danielkcz commented 5 years ago

It looks like that trying to style a custom component (not just div) is still not working? I do have the latest React and SC types packages and TypeScript 3.2.1.

image