Skip to content
Closed
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion packages/material-ui-styles/src/withStyles/withStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,7 @@ export default function withStyles<
>(
style: S,
options?: Options,
): PropInjector<WithStyles<S, Options['withTheme']>, StyledComponentProps<ClassKeyOfStyles<S>>>;
): PropInjector<
WithStyles<S, Options['withTheme']>,
StyledComponentProps<ClassKeyOfStyles<S>> & PropsOfStyles<S>
>;
9 changes: 7 additions & 2 deletions packages/material-ui-styles/test/styles.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -355,10 +355,11 @@ withStyles(theme =>
// styles from props
interface StyleProps {
color?: 'blue' | 'red';
default: 'green' | 'yellow';
}

const styles = (theme: Theme) => ({
root: (props: StyleProps) => ({ backgroundColor: props.color || theme.palette.primary.main }),
root: (props: StyleProps) => ({ backgroundColor: props.color || props.default }),
});

interface MyComponentProps extends WithStyles<typeof styles> {
Expand All @@ -377,7 +378,11 @@ withStyles(theme =>
}

const StyledMyComponent = withStyles(styles)(MyComponent);
const renderedStyledMyComponent = <StyledMyComponent message="Hi" />;
const renderedStyledMyComponentNoDefault = <StyledMyComponent message="Hi" />; // $ExpectError
const renderedStyledMyComponentWithDefault = <StyledMyComponent message="Hi" default="green" />;
const renderedStyledMyComponentBlue = (
<StyledMyComponent message="Hi" default="green" color="blue" />
);

// number is not assignable to 'blue' | 'red'
// $ExpectError
Expand Down