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

styled-components v5: flow types themselves fail flow lint #3813

Open
walkerdb opened this issue Apr 22, 2020 · 3 comments
Open

styled-components v5: flow types themselves fail flow lint #3813

walkerdb opened this issue Apr 22, 2020 · 3 comments

Comments

@walkerdb
Copy link

Do you want to request a feature or report a bug?
Bug in styled-components v5 flow types.

What is the current behavior?
Latest styled-components flow types produce a flow error.

To reproduce, just install latest flow, pull down the latest styled-components flow types, and run flow.

This error will result:

Error ┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈ flow-typed/npm/styled-components_v5.x.x.js:416:39

Missing type annotation for V. V is a type parameter declared in function type [1] and was implicitly instantiated at
$ObjMap [2].

     413│     ElementName
     414│   >;
     415│
 [2] 416│   declare type ConvenientShorthands = $ObjMap<
     417│     BuiltinElementInstances,
 [1] 418│     <V>(V) => StyledShorthandFactory<V>
     419│   >;
     420│
     421│   declare interface Styled {
     422│     <Comp: React$ComponentType<P>, Theme, OwnProps = React$ElementConfig<Comp>>(

What is the expected behavior?
Flow type should be valid

Local Environment Information
Flow v. 0.123.0 (also reproduces on at least 0.122.0, haven't tried on others), latest styled-components v5 flow types.

@walkerdb
Copy link
Author

cc @omninonsense

@omninonsense
Copy link
Contributor

omninonsense commented Apr 22, 2020

Hi @walkerdb!

I'm aware of this issue, but I'm not sure how to fix it. I'm not even sure if it's a bug with the libdef or a bug in Flow.

But, generally, it happens when people forget to call one of the shorthands, e.g:

// Error
const C = styled.div

vs

// Fine
const C = styled.div``

Someone made a stripped down version of the libdef that reproduces the error and they've opened an issue Flow (facebook/flow#8344)

@gwing33
Copy link

gwing33 commented Jul 10, 2020

I'm upgrading from an old flow version (v0.79.1), it took me a while to figure out what was going on. Found out this is causing me issues:

// $FlowFixMe[missing-annot] Upgrade Flow to v0.129.0.
export const MyDiv = styled.div``;

It correctly suppresses the error in the file but bubbles it up to the styled-components libdef. This doesn't seem like a libdef issue, but rather a flow issue.

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

3 participants