Skip to content

Commit 2472823

Browse files
committed
[styles] Fix styled types not including properties
1 parent 9e96a44 commit 2472823

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

packages/material-ui-styles/src/styled/styled.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import {
66
} from '@material-ui/styles/withStyles';
77
import * as React from 'react';
88

9+
/**
10+
* If props is any, returns empty object, otherwise T
11+
* @internal
12+
*/
13+
export type GetProps<T> = 0 extends 1 & T ? {} : T;
14+
915
/**
1016
* @internal
1117
*/
@@ -19,7 +25,7 @@ export type ComponentCreator<Component extends React.ElementType> = <Theme, Prop
1925
JSX.LibraryManagedAttributes<Component, React.ComponentProps<Component>>,
2026
'classes' | 'className'
2127
> &
22-
StyledComponentProps<'root'> & { className?: string }
28+
StyledComponentProps<'root'> & { className?: string } & GetProps<Props>
2329
>;
2430

2531
export interface StyledProps {

packages/material-ui-styles/test/index.spec.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,9 @@ import styled, { StyledProps } from '@material-ui/styles/styled';
155155
interface MyTheme {
156156
fontFamily: string;
157157
}
158+
const MyThemeInstance: MyTheme = {
159+
fontFamily: 'monospace',
160+
};
158161
// tslint:disable-next-line: no-empty-interface
159162
interface MyComponentProps extends StyledProps {
160163
defaulted: string;
@@ -176,7 +179,7 @@ import styled, { StyledProps } from '@material-ui/styles/styled';
176179
const renderedMyComponent = (
177180
<>
178181
<MyComponent className="test" />
179-
<StyledMyComponent />
182+
<StyledMyComponent theme={MyThemeInstance} />
180183
</>
181184
);
182185
}

0 commit comments

Comments
 (0)