Created
July 6, 2018 17:15
-
-
Save HenriBeck/438f0cbd6c6168ccced47287b0d61f0e to your computer and use it in GitHub Desktop.
React JSS Typings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// @flow strict-local | |
import { | |
type ComponentType, | |
type ElementConfig | |
} from 'react'; | |
import type Jss from '../../packages/webapp/node_modules/jss/src/Jss'; | |
import type SheetsRegistry from '../../packages/webapp/node_modules/jss/src/SheetsRegistry'; | |
import { type generateClassName } from '../../packages/webapp/node_modules/jss/src/types/jss'; | |
declare module 'react-jss' { | |
declare type Options = { index?: number }; | |
declare type ExtractReturnType = <R>(() => R) => R; | |
declare export type Styles = { [key: string]: string | number | Styles }; | |
declare export type StaticStyles = { [key: string]: Styles }; | |
declare export type ThemedStyles = (theme: {}) => StaticStyles; | |
declare export type StaticClasses<Styles: StaticStyles> = { [key: $Keys<Styles>]: string }; | |
declare export type ThemedClasses<Styles: ThemedStyles> = { | |
[key: $Keys<$Call<Styles, ExtractReturnType>>]: string, | |
}; | |
declare type HOC<Comp: ComponentType> = ComponentType< | |
$Diff<ElementConfig<Comp>, { classes: {} }>, | |
>; | |
declare export class JssProvider extends React$Component<{ | |
registry: SheetsRegistry, | |
jss: Jss, | |
classNamePrefix: string, | |
generateClassName: generateClassName, | |
disableStylesGeneration: boolean, | |
}> {} | |
declare export default function injectSheet< | |
Styles: StaticStyles, | |
Props: { classes: StaticClasses<Styles> }, | |
Comp: ComponentType<Props>, | |
>(styles: Styles, options?: Options): (comp: Comp) => HOC<Comp>; | |
declare export default function injectSheet< | |
Styles: ThemedStyles, | |
Props: { classes: ThemedClasses<Styles> }, | |
Comp: ComponentType<Props>, | |
>(styles: Styles, options?: Options): (comp: Comp) => HOC<Comp>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment