Flow doesn't return error with styled-components
See original GitHub issueEnvironment
Binaries:
- Node: 10.12.0 - /usr/bin/node
- Yarn: 1.10.1 - /usr/bin/yarn
- npm: 6.4.1 - /usr/bin/npm
npmPackages:
- babel-plugin-styled-components: ^1.5.1 => 1.5.1
- styled-components: ^4.0.0-beta.10 => 4.0.0-beta.10
Reproduction
git clone https://github.com/ravecat/styled-components-toolbox.git --single-branch --branch feature/migrate-to-flow
yarn
git commit --amend
and can see console output
$ flow check Found 0 errors
Steps to reproduce
Create Button.js
file with flow. Specifically indicated the wrong type for the variable (highlighted comment)
Button.js
/* @flow */
import React from "react";
import styled, { css, type ReactComponentStyled } from "styled-components";
import BaseComponent, { BaseProps } from "common/components/BaseComponent";
type ButtonProps = BaseProps & {
type?: string,
href?: string,
disabled?: boolean
};
const Button = ({ children, ...rest }: ButtonProps) => (
// TODO Set wrong type for test flow
<Wrapper as="button" type={42} {...rest}>
<span>{children}</span>
</Wrapper>
);
const Wrapper: ReactComponentStyled<ButtonProps> = styled(BaseComponent).attrs({
type: ({ type }) => type || "button"
})`
display: inline-block;
height: 32px;
padding: 0 15px;
line-height: 30px;
text-align: center;
letter-spacing: normal;
cursor: pointer;
outline: 0;
white-space: nowrap;
color: ${({ theme }) => theme.textColor};
background: ${({ theme }) => theme.primaryColor};
border: 1px solid ${({ theme }) => theme.primaryColor};
border-radius: 0;
:hover {
background: ${({ theme }) => theme.textColor};
color: ${({ theme }) => theme.primaryColor};
}
${({ disabled }) =>
disabled &&
css`
&& {
cursor: default;
background: ${({ theme }) => theme.textColor};
border-color: ${({ theme }) => theme.dividerColor};
color: ${({ theme }) => theme.dividerColor};
}
`};
`;
export default Button;
Expected Behavior
Flow return error
Actual Behavior
Flow check without error
Probably, this issue related with https://github.com/styled-components/styled-components/issues/1349 , but I cannot get answer on that problem.
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Flow doesn't return error with styled-components · Issue #2201 ...
Flow doesn't return error with styled-components #2201 ... --branch feature/migrate-to-flow; yarn; git commit --amend and can see console output.
Read more >Flow type & Styled-components errors when imported
I saw in a comment to use libdef 1.4, but when I run yarn add --dev flow-typed@1.4 I only get version 1 or...
Read more >API Reference - styled-components
Returns a StyledComponent that does not accept children. Place it at the top of your React tree and the global styles will be...
Read more >Using Styled Components and Flow with Create React App
If you try importing styled-components, you will notice that flow complains that it cannot find the module. This is because styled components ...
Read more >How to use styled-components with React Native
In this tutorial, we'll discuss what advantages a library like styled-components has over the general StyleSheet manager in React Native.
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
Yep, absolutely right. As I understand current issue depends on lack of libdef? if it is true you can close issue
https://github.com/flow-typed/flow-typed/pull/2933