Skip to content

Commit

Permalink
Fix flow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Aug 23, 2020
1 parent cacfbb9 commit 81a6877
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/styled/src/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,6 @@ let createStyled: CreateStyled = (tag: any, options?: StyledOptions) => {
Styled.__emotion_real = Styled
Styled.__emotion_base = baseTag
Styled.__emotion_styles = styles
Styled.__emotion_identifier = identifierName
Styled.__emotion_forwardProp = shouldForwardProp

Object.defineProperty(Styled, 'toString', {
Expand All @@ -191,6 +190,7 @@ let createStyled: CreateStyled = (tag: any, options?: StyledOptions) => {
) => {
return createStyled(nextTag, {
...options,
// $FlowFixMe
...nextOptions,
shouldForwardProp: composeShouldForwardProps(Styled, nextOptions, true)
})(...styles)
Expand Down
11 changes: 6 additions & 5 deletions packages/styled/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,18 @@ export const getDefaultShouldForwardProp = (tag: ElementType) =>

export const composeShouldForwardProps = (
tag: PrivateStyledComponent<any>,
options: StyledOptions | undefined,
options: StyledOptions | void,
isReal: boolean
) => {
let shouldForwardProp
if (options) {
const optionsShouldForwardProp = options.shouldForwardProp
shouldForwardProp =
tag.__emotion_forwardProp && options.shouldForwardProp
? propName =>
tag.__emotion_forwardProp && optionsShouldForwardProp
? (propName: string) =>
tag.__emotion_forwardProp(propName) &&
options.shouldForwardProp(propName)
: options.shouldForwardProp // $FlowFixMe
optionsShouldForwardProp(propName)
: optionsShouldForwardProp
}

if (typeof shouldForwardProp !== 'function' && isReal) {
Expand Down

0 comments on commit 81a6877

Please sign in to comment.