Skip to content

Commit a27b9ac

Browse files
dru89Drew Hays
andauthored
fix: allow partial classes prop in withStyles (#1428)
The `classes` prop created by the `withStyles` function is meant to be an optional parameter where you can provide some or all of the style classes. Co-authored-by: Drew Hays <drew.hays@hulu.com>
1 parent 56205c1 commit a27b9ac

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

packages/react-jss/src/index.d.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ declare const JssContext: Context<{
3737
disableStylesGeneration: boolean
3838
}>
3939

40+
type ClassesForStyles<S extends Styles | ((theme: any) => Styles)> = Classes<
41+
S extends (theme: any) => Styles ? keyof ReturnType<S> : keyof S
42+
>
43+
4044
interface WithStylesProps<S extends Styles | ((theme: any) => Styles)> {
41-
classes: Classes<S extends (theme: any) => Styles ? keyof ReturnType<S> : keyof S>
45+
classes: ClassesForStyles<S>
4246
}
4347
/**
4448
* @deprecated Please use `WithStylesProps` instead
@@ -86,8 +90,10 @@ declare function withStyles<
8690
) => ComponentType<
8791
JSX.LibraryManagedAttributes<
8892
C,
89-
Omit<GetProps<C>, 'classes'> &
90-
Partial<WithStylesProps<S>> & {innerRef?: RefObject<any> | ((instance: any) => void)}
93+
Omit<GetProps<C>, 'classes'> & {
94+
classes?: Partial<ClassesForStyles<S>>
95+
innerRef?: RefObject<any> | ((instance: any) => void)
96+
}
9197
>
9298
>
9399

0 commit comments

Comments
 (0)