Skip to content

Commit

Permalink
[system] Use the CustomSystemProps interface in Box Props
Browse files Browse the repository at this point in the history
  • Loading branch information
IgnusG committed May 15, 2023
1 parent b969bf6 commit 102d4e0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
1 change: 1 addition & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,7 @@ jobs:
yarn workspace @mui/material typescript:module-augmentation
yarn workspace @mui/base typescript:module-augmentation
yarn workspace @mui/joy typescript:module-augmentation
yarn workspace @mui/system typescript:module-augmentation
- restore_cache:
name: Restore generated declaration files
Expand Down
5 changes: 2 additions & 3 deletions packages/mui-system/src/Box/Box.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
AllSystemCSSProperties,
ResponsiveStyleValue,
OverwriteCSSProperties,
AliasesCSSProperties,
} from '../styleFunctionSx';

export type PropsFor<SomeStyleFunction> = SomeStyleFunction extends StyleFunction<infer Props>
Expand Down Expand Up @@ -141,7 +140,7 @@ export type ComposedStyleFunction<T extends Array<StyleFunction<any>>> = StyleFu
ComposedOwnerState<T>
> & { filterProps: string[] };

export interface CustomSystemProps extends AliasesCSSProperties, OverwriteCSSProperties {}
export interface CustomSystemProps extends OverwriteCSSProperties {}

export type SimpleSystemKeys = keyof PropsFor<
ComposedStyleFunction<
Expand All @@ -168,7 +167,7 @@ export type SystemProps<Theme extends object = {}> = {
[K in StandardSystemKeys]?:
| ResponsiveStyleValue<AllSystemCSSProperties[K]>
| ((theme: Theme) => ResponsiveStyleValue<AllSystemCSSProperties[K]>);
};
} & CustomSystemProps;

export interface BoxTypeMap<P = {}, D extends React.ElementType = 'div', T extends object = Theme> {
props: P &
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import * as React from 'react';
import { Box } from '@mui/system';

declare module '@mui/system' {
interface CustomSystemProps {
customProp?: 'customValue';
}
}

function CustomSystemPropsTest() {
<Box customProp="customValue" />;
}

function InvalidCustomSystemPropsValueTest() {
// @ts-expect-error otherCustomValue is not assignable to customValue
<Box customProp="otherCustomValue" />;
}

function UndefinedCustomSystemPropsTest() {
// @ts-expect-error otherCustomProp is not defined in CustomSystemProps
<Box otherCustomProp="customValue" />;
}

0 comments on commit 102d4e0

Please sign in to comment.