Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: improve Styled type to accept optional props type
- Loading branch information
Showing
5 changed files
with
130 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
--- | ||
'@emotion/styled-base': patch | ||
'@emotion/styled': patch | ||
--- | ||
|
||
Fixed package's Flow types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import createStyled from '../src' | ||
import type { CreateStyledComponent } from '../src/utils' | ||
|
||
export const valid: CreateStyledComponent = createStyled('div') | ||
|
||
// $FlowExpectError: we can't cast a StyledComponent to string | ||
export const invalid: string = createStyled('div') | ||
|
||
const styled = createStyled('div') | ||
type Props = { color: string } | ||
const Div = styled<Props>({ color: props => props.color }) | ||
|
||
export const validProp = <Div color="red" /> | ||
|
||
// $FlowExpectError: color property should be a string | ||
export const invalidProp = <Div color={2} /> | ||
|
||
// $FlowExpectError: we don't expose the private StyledComponent properties | ||
export const invalidPropAccess = styled().__emotion_base |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.