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.

Styled-components default export is unknown type

See original GitHub issue

Why default export of the styled-components package is unknown.

Example code:

// @flow

import * as React from 'react';
import styled from 'styled-components';

const A = styled.a`
  color: red;
`;

const B: React.ComponentType<{ children: React.Node }> = ({ children }) => (
  <a>{children}</a>
);

const C = styled(B)`
  color: blue;
`;

styled is typed as unknown, maybe this is because of weird $call property in module.exports. This refers to https://github.com/facebook/flow/issues/2966.

https://github.com/flowtype/flow-typed/blob/master/definitions/npm/styled-components_v3.x.x/flow_v0.57.x-/styled-components_v3.x.x.js#L347

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
Gpxcommented, Jun 25, 2018

I think I hit the same issue when updating Flow to 0.75.0. I now get:

Cannot call styled because a callable signature is missing in object type [1].

    flow-typed/npm/styled-components_v3.x.x.js
 [1] 494│   declare export default {
     495│     $call: $npm$styledComponents$Call<ComponentListKeys>,
     496│     styled: $npm$styledComponents$Call<ComponentListKeys>,
     497│     css: TaggedTemplateLiteral<Array<Interpolation>>,
     498│     ...$npm$styledComponents$StyledComponentsComponentList,
     499│     ...$npm$styledComponents$StyledComponentsNativeComponentList,
     500│   }

@shrynx can you please share the hotfix so I can test it?

1reaction
zalishchukcommented, May 27, 2018

@shrynx tried to killall flow, restarting flow server, nothing changed.

{
  "flow-bin": "^0.73.0",
  "styled-components": "^3.3.0"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Styled-components not exporting - Stack Overflow
import styled from "styled-components"; export default { colors: { black: "rgba(0,0,0,1)", brandPrimary: "rgba(238,120,36,1)", brandPrimaryLight ...
Read more >
API Reference - styled-components
This is the default export. This is a low-level factory we use to create the styled.tagname helper methods. Arguments, Description ...
Read more >
styled-jsx - npm
In styled-jsx styles can be defined outside of the component's render method or in separate JavaScript modules using the styled-jsx/css library.
Read more >
Useful Patterns by Use Case - React TypeScript Cheatsheets
export function Button(props: ButtonProps) { ... Usecase: same as above, but for a React Component you don't have access to the underlying ......
Read more >
Portable Text to React - Sanity.io
You can pass an object of components to use, both to override the defaults and to provide components for your custom content types....
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