Skip to content

Commit

Permalink
update typing / fix regression with polymorphism
Browse files Browse the repository at this point in the history
  • Loading branch information
jonathantneal committed Jul 22, 2021
1 parent 1b88833 commit 1445171
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
6 changes: 5 additions & 1 deletion packages/core/types/styled-component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ export interface CssComponent<
& {
[name in number | string]: any
}
): React.ReactElement | null
): {
className: string
selector: string
props: object
}

[$$StyledComponentType]: TagName
[$$StyledComponentProps]: Props
Expand Down
15 changes: 10 additions & 5 deletions packages/react/types/styled-component.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ export interface StyledComponent<
> extends ForwardRefExoticComponent<TagName, TransformedProps> {
<As = TagName>(
props:
As extends ''
? { as: keyof JSX.IntrinsicElements, css?: CSS }
As extends keyof JSX.IntrinsicElements
? Util.Assign<JSX.IntrinsicElements[As], Partial<TransformedProps> & { as?: As, css?: CSS }>
: As extends React.ComponentType<infer P>
? Util.Assign<P, Partial<TransformedProps> & { as?: As, css?: CSS }>
: As extends keyof JSX.IntrinsicElements
? Util.Assign<JSX.IntrinsicElements[As], TransformedProps & { as?: As, css?: CSS }>
: never
): React.ReactElement | null

Expand Down Expand Up @@ -49,7 +47,14 @@ export interface CssComponent<
& {
[name in number | string]: any
}
): React.ReactElement | null
): {
className: string
selector: string
props: object
}

className: string
selector: string

[$$StyledComponentType]: TagName
[$$StyledComponentProps]: Props
Expand Down

0 comments on commit 1445171

Please sign in to comment.