Describe the bug:
I have React & TypeScript project where JSS is used.
Here is a simple component:
import React, { Component } from 'react';
type TestProps<T> = {
data?: T[];
onClick?: (item: T) => void;
};
class Test<T> extends Component<TestProps<T>> {
render() {
return <></>;
}
}
export default Test;
If I check the types that compiled from this code it would be:
import { Component } from 'react';
declare type TestProps<T> = {
data?: T[];
onClick?: (item: T) => void;
};
declare class Test<T> extends Component<TestProps<T>> {
render(): JSX.Element;
}
export default Test;
So everything is OK here.
Now I want to add JSS styles here, so I change the component following way:
import React, { Component } from 'react';
import withStyles, { WithStylesProps } from 'react-jss';
import { JssStyle } from 'jss';
type CssStyles = 'root';
type ICssStyles = Record<CssStyles, JssStyle>;
const styles: ICssStyles = {
root: {
color: 'red'
}
};
type TestProps<T> = {
data?: T[];
onClick?: (item: T) => void;
} & WithStylesProps<ICssStyles>;
class Test<T> extends Component<TestProps<T>> {
render() {
return <>...</>;
}
}
export default withStyles(styles)(Test);
Once withStyles HOC is applied to the component, we lose T type and it's going to be unknown:
import React from 'react';
import { WithStylesProps } from 'react-jss';
import { JssStyle } from 'jss';
declare type CssStyles = 'root';
declare type ICssStyles = Record<CssStyles, JssStyle>;
declare type TestProps<T> = {
data?: T[];
onClick?: (item: T) => void;
} & WithStylesProps<ICssStyles>;
declare const _default: React.ComponentType<Pick<TestProps<unknown>, "data" | "onClick"> & {
classes?: Partial<Record<"root", string>> | undefined;
}>;
export default _default;

Expected behavior:
We should be able to use the generic parameter of the component after applying withStyles HOC.
Versions (please complete the following information):
- jss: 10.1.1
- react-jss: 10.1.1
- Browser [e.g. chrome, safari]: Chrome
- OS [e.g. Windows, macOS]: macOS
Describe the bug:
I have React & TypeScript project where JSS is used.
Here is a simple component:
If I check the types that compiled from this code it would be:
So everything is OK here.
Now I want to add JSS styles here, so I change the component following way:
Once
withStylesHOC is applied to the component, we loseTtype and it's going to beunknown:Expected behavior:
We should be able to use the generic parameter of the component after applying
withStylesHOC.Versions (please complete the following information):