diff --git a/types/styled-components/test/index.tsx b/types/styled-components/test/index.tsx index a37c33f315..067cdc7d89 100644 --- a/types/styled-components/test/index.tsx +++ b/types/styled-components/test/index.tsx @@ -1030,3 +1030,32 @@ const WrapperFunc = (props: WrapperProps) =>
; const StyledWrapperFunc = styled(WrapperFunc)``; // No `children` in props, so this should generate an error const wrapperFunc = Text; // $ExpectError + +function unionTest() { + interface Book { + kind: 'book'; + author: string; + } + + interface Magazine { + kind: 'magazine'; + issue: number; + } + + type SomethingToRead = (Book | Magazine); + + const Readable: React.FunctionComponent = props => { + if (props.kind === 'magazine') { + return
magazine #{props.issue}
; + } + + return
magazine #{props.author}
; + }; + + const StyledReadable = styled(Readable)` + font-size: ${props => props.kind === 'book' ? 16 : 14} + `; + + ; + ; // $ExpectError +}