Skip to content

add typings to new feature: mapThemrProps #60

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

Merged
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
9 changes: 7 additions & 2 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,21 @@ declare module "react-css-themr" {
type TReactCSSThemrTheme = {
[key: string]: string | TReactCSSThemrTheme
}
type TMapThemrProps<P> = (ownProps: P, theme: TReactCSSThemrTheme) => P & { theme: TReactCSSThemrTheme }

export function themeable(...themes: Array<TReactCSSThemrTheme>): TReactCSSThemrTheme;

export interface IThemrOptions {
/** @default "deeply" */
composeTheme?: "deeply" | "softly" | false,
//currently there's no way to lift decorated component's generic type argument (P) to upper decorator
//that's why just {}
mapThemrProps?: TMapThemrProps<{}>
}

export interface ThemeProviderProps {
innerRef?: Function,
theme: {}
theme: TReactCSSThemrTheme
}

export class ThemeProvider extends React.Component<ThemeProviderProps, any> {
Expand All @@ -31,5 +35,6 @@ declare module "react-css-themr" {
identifier: string | number | symbol,
defaultTheme?: {},
options?: IThemrOptions
): <P, S>(component: (new(props?: P, context?: any) => React.Component<P, S>) | React.SFC<P>) => ThemedComponentClass<P, S>;
): <P, S>(component: (new(props?: P, context?: any) => React.Component<P, S>) | React.SFC<P>) =>
ThemedComponentClass<P & { mapThemrProps?: TMapThemrProps<P> }, S>;
}