Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit ce6c7b0

Browse files
raveclassicjavivelasco
authored andcommitted
add typings to new feature: mapThemrProps (#60)
* add typing to new feature: mapThemrProps * fix
1 parent 670c85d commit ce6c7b0

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

‎index.d.ts‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,21 @@ declare module "react-css-themr" {
44
type TReactCSSThemrTheme = {
55
[key: string]: string | TReactCSSThemrTheme
66
}
7+
type TMapThemrProps<P> = (ownProps: P, theme: TReactCSSThemrTheme) => P & { theme: TReactCSSThemrTheme }
78

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

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

1519
export interface ThemeProviderProps {
1620
innerRef?: Function,
17-
theme: {}
21+
theme: TReactCSSThemrTheme
1822
}
1923

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

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /