2018-03-23 17:16:13 +03:00
|
|
|
import * as styledComponents from 'styled-components';
|
|
|
|
|
|
|
|
// Styled components typings for using babel-plugin BEFORE typescript
|
|
|
|
declare module 'styled-components' {
|
2018-10-18 11:48:17 +03:00
|
|
|
type Attrs<P, A extends Partial<P>, T> = {
|
|
|
|
[K in keyof A]: ((props: ThemedStyledProps<P, T>) => A[K]) | A[K]
|
|
|
|
};
|
|
|
|
type KeyofBase = keyof any;
|
|
|
|
type Diff<T extends KeyofBase, U extends KeyofBase> = ({ [P in T]: P } & { [P in U]: never })[T];
|
|
|
|
type DiffBetween<T, U> = Pick<T, Diff<keyof T, keyof U>> & Pick<U, Diff<keyof U, keyof T>>;
|
2018-03-23 17:16:13 +03:00
|
|
|
interface ThemedStyledFunction<P, T, O = P> {
|
|
|
|
// adding "| string[]" for transpileTemplateLiterals and similar below
|
|
|
|
(
|
|
|
|
strings: TemplateStringsArray | string[],
|
2018-10-18 11:48:17 +03:00
|
|
|
...interpolations: Array<Interpolation<ThemedStyledProps<P, T>>>
|
2018-03-23 17:16:13 +03:00
|
|
|
): StyledComponentClass<P, T, O>;
|
2018-10-18 11:48:17 +03:00
|
|
|
<U>(
|
2018-03-23 17:16:13 +03:00
|
|
|
strings: TemplateStringsArray | string[],
|
2018-10-18 11:48:17 +03:00
|
|
|
...interpolations: Array<Interpolation<ThemedStyledProps<P & U, T>>>
|
2018-03-23 17:16:13 +03:00
|
|
|
): StyledComponentClass<P & U, T, O & U>;
|
2018-10-18 11:48:17 +03:00
|
|
|
attrs<U, A extends Partial<P & U> = {}>(
|
|
|
|
attrs: Attrs<P & U, A, T>,
|
|
|
|
): ThemedStyledFunction<DiffBetween<A, P & U>, T, DiffBetween<A, O & U>>;
|
2018-03-23 17:16:13 +03:00
|
|
|
|
|
|
|
// adding "withConfig" for transpileTemplateLiterals
|
|
|
|
withConfig(config: any): ThemedStyledFunction<P, T, O>;
|
|
|
|
}
|
|
|
|
|
2018-10-18 11:48:17 +03:00
|
|
|
export interface BaseThemedCssFunction<T> {
|
2018-03-23 17:16:13 +03:00
|
|
|
(
|
|
|
|
strings: TemplateStringsArray | string[],
|
|
|
|
...interpolations: SimpleInterpolation[]
|
|
|
|
): InterpolationValue[];
|
|
|
|
<P>(
|
|
|
|
strings: TemplateStringsArray | string[],
|
2018-10-18 11:48:17 +03:00
|
|
|
...interpolations: Array<Interpolation<ThemedStyledProps<P, T>>>
|
|
|
|
): Array<FlattenInterpolation<ThemedStyledProps<P, T>>>;
|
2018-03-23 17:16:13 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
interface ThemedStyledComponentsModule<T> {
|
|
|
|
keyframes(
|
|
|
|
strings: TemplateStringsArray | string[],
|
|
|
|
...interpolations: SimpleInterpolation[]
|
2018-10-18 11:48:17 +03:00
|
|
|
): Keyframes;
|
|
|
|
|
|
|
|
createGlobalStyle<P = {}>(
|
2018-03-23 17:16:13 +03:00
|
|
|
strings: TemplateStringsArray | string[],
|
2018-10-18 11:48:17 +03:00
|
|
|
...interpolations: Array<Interpolation<ThemedStyledProps<P, T>>>
|
|
|
|
): GlobalStyleClass<P, T>;
|
2018-03-23 17:16:13 +03:00
|
|
|
}
|
|
|
|
}
|