Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make WithStylesOptions extend the options argument of createStyleSheet #11325

Merged
merged 6 commits into from
May 12, 2018
Merged
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
2 changes: 1 addition & 1 deletion packages/material-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.42",
"@types/jss": "^9.3.0",
"@types/jss": "^9.5.3",
"@types/react-transition-group": "^2.0.8",
"brcast": "^3.0.1",
"classnames": "^2.2.5",
Expand Down
5 changes: 3 additions & 2 deletions packages/material-ui/src/styles/withStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { WithTheme } from '../styles/withTheme';
import { ConsistentWith, Overwrite } from '..';
import { Theme } from './createMuiTheme';
import * as CSS from 'csstype';
import * as JSS from 'jss'

export interface CSSProperties extends CSS.Properties<number | string> {
// Allow pseudo selectors and media queries
Expand All @@ -28,7 +29,7 @@ export interface StylesCreator {
themingEnabled: boolean;
}

export interface WithStylesOptions {
export interface WithStylesOptions<ClassKey extends string = string> extends JSS.CreateStyleSheetOptions<ClassKey> {
flip?: boolean;
withTheme?: boolean;
name?: string;
Expand All @@ -47,7 +48,7 @@ export interface StyledComponentProps<ClassKey extends string = string> {

export default function withStyles<ClassKey extends string>(
style: StyleRules<ClassKey> | StyleRulesCallback<ClassKey>,
options?: WithStylesOptions,
options?: WithStylesOptions<ClassKey>,
): {
<P extends ConsistentWith<P, StyledComponentProps<ClassKey>>>(
component: React.ComponentType<P & WithStyles<ClassKey>>,
Expand Down
4 changes: 4 additions & 0 deletions packages/material-ui/test/typescript/styles.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,3 +317,7 @@ withStyles<'listItem' | 'guttered'>(theme => ({

<DecoratedSomeComponent someProp="hello world" />;
}

{ // https://github.com/mui-org/material-ui/issues/11312
withStyles(styles, { name: "MyComponent", index: 0 })(() => <div/>);
}
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -949,9 +949,9 @@
"@types/minimatch" "*"
"@types/node" "*"

"@types/jss@^9.3.0":
version "9.5.2"
resolved "https://registry.yarnpkg.com/@types/jss/-/jss-9.5.2.tgz#85076b2c16606a6f996aa7e20c1ec7ed6a08075f"
"@types/jss@^9.3.0", "@types/jss@^9.5.3":
version "9.5.3"
resolved "https://registry.yarnpkg.com/@types/jss/-/jss-9.5.3.tgz#0c106de3fe0b324cd4173fac7dab26c12cda624e"
dependencies:
csstype "^2.0.0"
indefinite-observable "^1.0.1"
Expand Down