= - | FlattenInterpolation
- | ReadonlyArray< - FlattenInterpolation
| ReadonlyArray =
| InterpolationValue
- | InterpolationFunction ;
+ | InterpolationFunction
+ | FlattenInterpolation ;
+// must be an interface to be self-referential
+export interface FlattenInterpolation
+ extends ReadonlyArray = (props: P) => Interpolation ;
@@ -76,9 +85,8 @@ type DeprecatedAttrs , T> = {
[K in keyof A]: ((props: ThemedStyledProps ) => A[K]) | A[K]
};
-export type ThemedGlobalStyledClassProps = P & {
- suppressMultiMountWarning?: boolean
- theme?: T
+export type ThemedGlobalStyledClassProps = WithOptionalTheme & {
+ suppressMultiMountWarning?: boolean;
};
export interface GlobalStyleComponent
@@ -86,8 +94,8 @@ export interface GlobalStyleComponent
// remove the call signature from StyledComponent so Interpolation can still infer InterpolationFunction
type StyledComponentInterpolation = Pick<
- StyledComponent (
- strings: TemplateStringsArray,
- ...interpolations: Array (func: InterpolationFunction (
+ first: NonNullable = Omit & {
- theme?: T
+type WithOptionalTheme = Omit & {
+ theme?: T;
};
export interface ThemedStyledComponentsModule (
- strings: TemplateStringsArray,
+ createGlobalStyle (
+ first: NonNullable ;
- createGlobalStyle (
- func: InterpolationFunction ;
withTheme: WithThemeFnInterface (
- strings: TemplateStringsArray,
+export function createGlobalStyle (
+ first: NonNullable ;
-export function createGlobalStyle (
- func: InterpolationFunction ;
export function isStyledComponent(
target: any
@@ -373,12 +376,12 @@ export class ServerStyleSheet {
type StyleSheetManagerProps =
| {
- sheet: ServerStyleSheet
- target?: never
+ sheet: ServerStyleSheet;
+ target?: never;
}
| {
- sheet?: never
- target: HTMLElement
+ sheet?: never;
+ target: HTMLElement;
};
export class StyleSheetManager extends React.Component<
diff --git a/types/styled-components/test/index.tsx b/types/styled-components/test/index.tsx
index 64e0f447ba..7ce9e59fa2 100644
--- a/types/styled-components/test/index.tsx
+++ b/types/styled-components/test/index.tsx
@@ -1,6 +1,6 @@
-import * as React from 'react';
-import * as ReactDOM from 'react-dom';
-import * as ReactDOMServer from 'react-dom/server';
+import * as React from "react";
+import * as ReactDOM from "react-dom";
+import * as ReactDOMServer from "react-dom/server";
import styled, {
css,
@@ -14,7 +14,8 @@ import styled, {
withTheme,
ThemeConsumer,
StyledComponent,
-} from 'styled-components';
+ ThemedStyledComponentsModule
+} from "styled-components";
/**
* general usage
@@ -72,8 +73,8 @@ const TomatoButton = styled(MyButton)`
const CustomizableButton = styled(MyButton)`
/* Adapt the colors based on primary prop */
- background: ${props => (props.primary ? 'palevioletred' : 'white')};
- color: ${props => (props.primary ? 'white' : 'palevioletred')};
+ background: ${props => (props.primary ? "palevioletred" : "white")};
+ color: ${props => (props.primary ? "white" : "palevioletred")};
font-size: 1em;
margin: 1em;
@@ -86,7 +87,7 @@ const example = css`
font-size: 1.5em;
text-align: center;
color: ${props => props.theme.primary};
- border-color: ${'red'};
+ border-color: ${"red"};
`;
const fadeIn = keyframes`
@@ -99,15 +100,15 @@ const fadeIn = keyframes`
`;
const animationRule = css`
- ${fadeIn} 1s infinite alternate;
+ ${fadeIn} 1s infinite alternate;
`;
const ComponentWithKeyframe = styled.div`
- animation: ${animationRule};
+ animation: ${animationRule};
`;
const theme = {
- main: 'mediumseagreen',
+ main: "mediumseagreen"
};
const ExampleGlobalStyle = createGlobalStyle`
@@ -130,7 +131,7 @@ class Example extends React.Component {
Hello
;
}
@@ -400,7 +401,7 @@ const ThemedMyComponent = withTheme(MyComponent);
// ref;
// }}/>;
const themedRef = React.createRef