Skip to content

Commit

Permalink
Allow type variable for ThemedStyledFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyunje Jun committed Jun 1, 2018
1 parent f2aff0d commit 3bb8dfa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
3 changes: 1 addition & 2 deletions typings/styled-components.d.ts
Expand Up @@ -40,8 +40,7 @@ export interface StyledComponentClass<P, T, O = P> extends ComponentClass<Themed
}

export interface ThemedStyledFunction<P, T, O = P> {
(strings: TemplateStringsArray, ...interpolations: Interpolation<ThemedStyledProps<P, T>>[]): StyledComponentClass<P, T, O>;
<U>(strings: TemplateStringsArray, ...interpolations: Interpolation<ThemedStyledProps<P & U, T>>[]): StyledComponentClass<P & U, T, O & U>;
<U = {}>(strings: TemplateStringsArray, ...interpolations: Interpolation<ThemedStyledProps<P & U, T>>[]): StyledComponentClass<P & U, T, O & U>;
attrs<U, A extends Partial<P & U> = {}>(attrs: Attrs<P & U, A, T>): ThemedStyledFunction<P & A & U, T, O & U>;
}

Expand Down
9 changes: 9 additions & 0 deletions typings/tests/typed-template-literal.tsx
@@ -0,0 +1,9 @@
import styled from "../..";

const plain = styled.h1`
color: ${props => props.className};
`;

const withTypeArgs = styled.h1<{ hello: string }>`
color: ${props => props.hello};
`;

0 comments on commit 3bb8dfa

Please sign in to comment.