Skip to content

Commit

Permalink
Minor TS types tweak in @emotion/styled
Browse files Browse the repository at this point in the history
  • Loading branch information
Andarist committed Aug 1, 2020
1 parent f57a722 commit 8f08aa2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/react/types/helper.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react'

/**
* @desc Utility type for getting props type of React component.
* It takes `defaultProps` into an account - making props with defaults optional.
*/
export type PropsOf<
C extends keyof JSX.IntrinsicElements | React.JSXElementConstructor<any>
Expand Down
4 changes: 2 additions & 2 deletions packages/styled/types/base.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ export interface CreateStyled {
> = keyof React.ComponentProps<C>
>(
component: C,
options: FilteringStyledOptions<PropsOf<C>, ForwardedProps>
options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>
): CreateStyledComponent<
Pick<PropsOf<C>, ForwardedProps> & {
theme?: Theme
Expand All @@ -115,7 +115,7 @@ export interface CreateStyled {

<C extends React.ComponentType<React.ComponentProps<C>>>(
component: C,
options?: StyledOptions<PropsOf<C>>
options?: StyledOptions<React.ComponentProps<C>>
): CreateStyledComponent<
PropsOf<C> & {
theme?: Theme
Expand Down
10 changes: 10 additions & 0 deletions packages/styled/types/tests-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -432,3 +432,13 @@ const Section = styled('section')`
`
;<StyledWithAs as="section" />
;<StyledWithAs as={Section} />

{
const MemoedComponent = React.memo((_props: { foo: string }) => {
return null
})
const StyledMemoedComponent = styled(MemoedComponent)()
;<StyledMemoedComponent foo="test" />
// $ExpectError
;<StyledMemoedComponent />
}

0 comments on commit 8f08aa2

Please sign in to comment.