[@types-baseui] Style override signature (#36633)

This commit is contained in:
Alex Zywiak
2019-07-11 14:55:40 -06:00
committed by Armando Aguirre
parent 1301cf09e3
commit 6723deba32
2 changed files with 13 additions and 2 deletions

View File

@@ -110,6 +110,17 @@ const NewStyledProgressSteps = styled<ProgressStepsStyleProps, typeof StyledProg
// Avatar
<Avatar name='user' size='10'/>;
<Avatar name='user' size={10}/>; // $ExpectError
<Avatar
name="user"
overrides={{ Root: { style: ({ $theme }) => ({ height: $theme.sizing && $theme.sizing.scale1000 }) } }}
/>;
<Avatar
name="user"
overrides={{ Root: { style: ({ $didImageFailToLoad }) => ({ height: $didImageFailToLoad ? '0' : '10px' }) } }}
/>;
<Avatar name="user" overrides={{ Root: { style: ({ children }) => ({ height: children ? '10px' : '0'})} }} />;
<Avatar name="user" overrides={{ Root: { style: ({ $theme }) => ({ height: $theme.sizing && $theme.sizing.notasize })} }} />; // $ExpectError
<Avatar name="user" overrides={{ Root: { style: ({ $nonExistantProp }) => ({}) }}} />; // $ExpectError
// Block
<Block as='h1'/>;

View File

@@ -1,9 +1,9 @@
type StyleOverride = object | ((props: any) => object);
type StyleOverride<T> = object | ((props: { $theme: Theme } & React.PropsWithChildren<T>) => object);
interface OverrideObject<T> {
component?: React.ComponentType<T>;
props?: object;
style?: StyleOverride;
style?: StyleOverride<T>;
}
type Override<T> = OverrideObject<T> | React.ComponentType<T>;