diff --git a/docs/pages/material-ui/api/input-label.json b/docs/pages/material-ui/api/input-label.json index 65861580971e2f..716c178dcf478a 100644 --- a/docs/pages/material-ui/api/input-label.json +++ b/docs/pages/material-ui/api/input-label.json @@ -16,7 +16,10 @@ "required": { "type": { "name": "bool" } }, "shrink": { "type": { "name": "bool" } }, "size": { - "type": { "name": "enum", "description": "'normal'
| 'small'" }, + "type": { + "name": "union", + "description": "'normal'
| 'small'
| string" + }, "default": "'normal'" }, "sx": { diff --git a/packages/mui-material/src/InputLabel/InputLabel.d.ts b/packages/mui-material/src/InputLabel/InputLabel.d.ts index 285ad1f64cb952..e15cdc45fe8972 100644 --- a/packages/mui-material/src/InputLabel/InputLabel.d.ts +++ b/packages/mui-material/src/InputLabel/InputLabel.d.ts @@ -1,10 +1,13 @@ import * as React from 'react'; import { SxProps } from '@mui/system'; +import { OverridableStringUnion } from '@mui/types'; import { InternalStandardProps as StandardProps } from '..'; import { FormLabelProps } from '../FormLabel'; import { Theme } from '../styles'; import { InputLabelClasses } from './inputLabelClasses'; +export interface InputLabelPropsSizeOverrides {} + export interface InputLabelProps extends StandardProps { /** * The content of the component. @@ -49,7 +52,7 @@ export interface InputLabelProps extends StandardProps { * The size of the component. * @default 'normal' */ - size?: 'small' | 'normal'; + size?: OverridableStringUnion<'small' | 'normal', InputLabelPropsSizeOverrides>; /** * The system prop that allows defining system overrides as well as additional CSS styles. */ diff --git a/packages/mui-material/src/InputLabel/InputLabel.js b/packages/mui-material/src/InputLabel/InputLabel.js index a6af7ad1b3c423..5318af7bd25fc2 100644 --- a/packages/mui-material/src/InputLabel/InputLabel.js +++ b/packages/mui-material/src/InputLabel/InputLabel.js @@ -224,7 +224,10 @@ InputLabel.propTypes /* remove-proptypes */ = { * The size of the component. * @default 'normal' */ - size: PropTypes.oneOf(['normal', 'small']), + size: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([ + PropTypes.oneOf(['normal', 'small']), + PropTypes.string, + ]), /** * The system prop that allows defining system overrides as well as additional CSS styles. */ diff --git a/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx b/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx new file mode 100644 index 00000000000000..42d25f1922ff95 --- /dev/null +++ b/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.spec.tsx @@ -0,0 +1,13 @@ +import * as React from 'react'; +import InputLabel from '@mui/material/InputLabel'; + +declare module '@mui/material/InputLabel' { + interface InputLabelPropsSizeOverrides { + customSize: true; + } +} + +; + +// @ts-expect-error unknown size +; diff --git a/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.tsconfig.json b/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.tsconfig.json new file mode 100644 index 00000000000000..f53a33cae0908f --- /dev/null +++ b/packages/mui-material/test/typescript/moduleAugmentation/InputLabelCustomProps.tsconfig.json @@ -0,0 +1,4 @@ +{ + "extends": "../../../../../tsconfig", + "files": ["InputLabelCustomProps.spec.tsx"] +}