Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add StyledComponent to allowed Interpolation types #635

Merged
merged 2 commits into from
May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion packages/react-emotion/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ export type InterpolationTypes<Props = {}> =

export type Interpolation<Props = {}> =
| InterpolationTypes<Props>
| Array<InterpolationTypes<Props>>;
| Array<InterpolationTypes<Props>>
| ComponentRef;

export interface Options {
string?: string;
Expand All @@ -34,8 +35,12 @@ type ElementProps<Tag extends keyof JSX.IntrinsicElements> =
& JSX.IntrinsicElements[Tag]
& { innerRef?: JSX.IntrinsicElements[Tag]['ref'] };

// tslint:disable:no-empty-interface
interface ComponentRef {}

export interface StyledComponent<Props, Theme, IntrinsicProps>
extends
ComponentRef,
ComponentClass<Props & IntrinsicProps>,
StatelessComponent<Props & IntrinsicProps> {
withComponent<Tag extends keyof JSX.IntrinsicElements>(tag: Tag):
Expand Down
13 changes: 13 additions & 0 deletions packages/react-emotion/types/tests.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,16 @@ mount = <Component innerRef={(element: HTMLDivElement) => {}} />;

Component = Component.withComponent('input');
mount = <Component innerRef={(element: HTMLInputElement) => {}} />;

/*
* Reference to other styled component
*/
const Child = styled.div`
color: red;
`;

const Parent = styled.div`
${Child} {
color: blue;
}
`;