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 Jan 19, 2023
1 parent f13e534 commit 2bdf0d7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
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
2 changes: 1 addition & 1 deletion packages/mui-system/src/Box/Box.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,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 2bdf0d7

Please sign in to comment.