Skip to content

Commit

Permalink
[core] run prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Aug 18, 2018
1 parent 740225c commit 55f217f
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 25 deletions.
7 changes: 5 additions & 2 deletions packages/material-ui/src/ButtonBase/TouchRipple.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import * as React from 'react';
import { TransitionGroup } from 'react-transition-group';
import { StandardProps } from '..';

export type TouchRippleProps = StandardProps<TransitionGroup.TransitionGroupProps, TouchRippleClassKey> & {
export type TouchRippleProps = StandardProps<
TransitionGroup.TransitionGroupProps,
TouchRippleClassKey
> & {
center?: boolean;
}
};

export type TouchRippleClassKey =
| 'root'
Expand Down
7 changes: 3 additions & 4 deletions packages/material-ui/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ export type AnyComponent<P = any> =
| (new (props: P) => React.Component)
| ((props: P & { children?: React.ReactNode }) => React.ReactElement<P> | null);

export type PropsOf<C extends AnyComponent> =
C extends new (props: infer P) => React.Component ? P :
C extends (props: infer P) => React.ReactElement<any> | null ? P :
never;
export type PropsOf<C extends AnyComponent> = C extends new (props: infer P) => React.Component
? P
: C extends (props: infer P) => React.ReactElement<any> | null ? P : never;

/**
* All standard components exposed by `material-ui` are `StyledComponents` with
Expand Down
20 changes: 12 additions & 8 deletions packages/material-ui/src/styles/withStyles.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,13 +38,14 @@ export interface WithStylesOptions<ClassKey extends string = string>

export type ClassNameMap<ClassKey extends string = string> = Record<ClassKey, string>;

export type WithStyles<T extends string | StyleRules | StyleRulesCallback = string, IncludeTheme extends boolean | undefined = undefined> =
(IncludeTheme extends true ? WithTheme : Partial<WithTheme>)
& {
classes: ClassNameMap<
T extends string
? T
: T extends StyleRulesCallback<infer K> ? K : T extends StyleRules<infer K> ? K : never
export type WithStyles<
T extends string | StyleRules | StyleRulesCallback = string,
IncludeTheme extends boolean | undefined = undefined
> = (IncludeTheme extends true ? WithTheme : Partial<WithTheme>) & {
classes: ClassNameMap<
T extends string
? T
: T extends StyleRulesCallback<infer K> ? K : T extends StyleRules<infer K> ? K : never
>;
};

Expand All @@ -53,7 +54,10 @@ export interface StyledComponentProps<ClassKey extends string = string> {
innerRef?: React.Ref<any> | React.RefObject<any>;
}

export default function withStyles<ClassKey extends string, Options extends WithStylesOptions<ClassKey>>(
export default function withStyles<
ClassKey extends string,
Options extends WithStylesOptions<ClassKey>
>(
style: StyleRulesCallback<ClassKey> | StyleRules<ClassKey>,
options?: Options,
): {
Expand Down
26 changes: 15 additions & 11 deletions packages/material-ui/test/typescript/styles.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -178,23 +178,27 @@ const AllTheComposition = withTheme()(
<AllTheComposition />;

{
const Foo = withTheme()(class extends React.Component<WithTheme> {
render() {
return null;
}
});
const Foo = withTheme()(
class extends React.Component<WithTheme> {
render() {
return null;
}
},
);

<Foo />
<Foo />;
}

declare const themed: boolean;
{
// Test that withTheme: true guarantees the presence of the theme
const Foo = withStyles({}, { withTheme: true })(class extends React.Component<WithTheme> {
render() {
return <div style={{ margin: this.props.theme.spacing.unit }} />;
}
});
const Foo = withStyles({}, { withTheme: true })(
class extends React.Component<WithTheme> {
render() {
return <div style={{ margin: this.props.theme.spacing.unit }} />;
}
},
);
<Foo />;

const Bar = withStyles({}, { withTheme: true })(({ theme }) => (
Expand Down

0 comments on commit 55f217f

Please sign in to comment.