Skip to content

Commit

Permalink
update types / improve support for function types
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Jul 22, 2021
1 parent 3d30987 commit 52d1f36
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/react/types/styled-component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ import type * as Util from './util'

/** Returns a new Styled Component. */
export interface StyledComponent<
TagName = 'span',
Type = 'span',
Props = {},
Media = Default.Media,
Theme = {},
ThemeMap = Default.ThemeMap,
Utils = {},
TransformedProps = TransformProps<Props, Media>,
CSS = CSSUtil.CSS<Media, Theme, ThemeMap, Utils>
> extends ForwardRefExoticComponent<TagName, TransformedProps> {
<As = TagName>(
> extends ForwardRefExoticComponent<Type, TransformedProps> {
<As = Type>(
props:
As extends keyof JSX.IntrinsicElements
? Util.Assign<JSX.IntrinsicElements[As], Partial<TransformedProps> & { as?: As, css?: CSS }>
Expand All @@ -23,7 +23,7 @@ export interface StyledComponent<
: never
): React.ReactElement | null

[$$StyledComponentType]: TagName
[$$StyledComponentType]: Type
[$$StyledComponentProps]: Props
[$$StyledComponentMedia]: Media
}
Expand Down Expand Up @@ -100,6 +100,8 @@ export type StyledComponentType<T extends any[]> = (
? 'span'
: T[0] extends string
? T[0]
: T[0] extends (props: any) => any
? T[0]
: T[0] extends { [$$StyledComponentType]: unknown }
? T[0][$$StyledComponentType]
: T extends [lead: any, ...tail: infer V]
Expand Down

0 comments on commit 52d1f36

Please sign in to comment.