Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/sw.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-env serviceworker */
/* global self */
// https://github.com/airbnb/javascript/issues/1632

// See https://developer.chrome.com/docs/workbox/remove-buggy-service-workers/
Expand Down
16 changes: 15 additions & 1 deletion eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,21 @@ export default defineConfig(
},
},
{
files: [`packages/*/src/*/*${EXTENSION_TS}`],
files: [`packages/*/src/**/*${EXTENSION_TS}`, `packages/*/src/**/*${EXTENSION_DTS}`],
ignores: [
'**/*.spec.*',
'**/*.test.*',
// deprecated library
'**/mui-joy/**/*',
// used internally, not used on app router yet
'**/mui-docs/**/*',
],
rules: {
'mui/add-undef-to-optional': 'error',
},
},
{
files: [`packages/*/src/**/*${EXTENSION_TS}`],
ignores: [
'**/*.spec.*',
'**/*.test.*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,21 +412,58 @@ function checkSymbol({
// but not
// { a?: React.ElementType, b: React.ReactElement }
// get around this by not using the TypeChecker
if (
declaration &&
ts.isPropertySignature(declaration) &&
declaration.type &&
ts.isTypeReferenceNode(declaration.type)
) {
const name = declaration.type.typeName.getText();
if (
name === 'React.ElementType' ||
name === 'React.ComponentType' ||
name === 'React.JSXElementConstructor' ||
name === 'React.ReactElement'
) {
if (declaration && ts.isPropertySignature(declaration) && declaration.type) {
// Helper to check if a type node is a React element type reference
const getElementTypeName = (typeNode: ts.TypeNode): string | null => {
if (ts.isTypeReferenceNode(typeNode)) {
const name = typeNode.typeName.getText();
if (
name === 'React.ElementType' ||
name === 'React.ComponentType' ||
name === 'React.JSXElementConstructor' ||
name === 'React.ReactElement'
) {
return name;
}
}
return null;
};

// Check for direct type reference (e.g., `prop: React.ElementType`)
let elementTypeName = getElementTypeName(declaration.type);

// Also check for union types like `React.ElementType | undefined`
// but NOT for unions with other types like `string | React.ReactElement | undefined`
if (!elementTypeName && ts.isUnionTypeNode(declaration.type)) {
let foundElementType: string | null = null;
let hasOtherNonUndefinedTypes = false;

for (const typeNode of declaration.type.types) {
const name = getElementTypeName(typeNode);
if (name) {
foundElementType = name;
} else if (
// Check if this is an undefined type (keyword or literal)
!(
typeNode.kind === ts.SyntaxKind.UndefinedKeyword ||
(ts.isLiteralTypeNode(typeNode) &&
typeNode.literal.kind === ts.SyntaxKind.UndefinedKeyword)
)
) {
// Found a type that's neither an element type nor undefined
hasOtherNonUndefinedTypes = true;
}
}

// Only use the element type if the union doesn't have other non-undefined types
if (foundElementType && !hasOtherNonUndefinedTypes) {
elementTypeName = foundElementType;
}
}

if (elementTypeName) {
const elementNode = createElementType({
elementType: name === 'React.ReactElement' ? 'element' : 'elementType',
elementType: elementTypeName === 'React.ReactElement' ? 'element' : 'elementType',
jsDoc,
});

Expand Down
16 changes: 8 additions & 8 deletions packages/mui-lab/src/Masonry/Masonry.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,38 +11,38 @@ export interface MasonryOwnProps {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<MasonryClasses>;
classes?: Partial<MasonryClasses> | undefined;
/**
* Number of columns.
* @default 4
*/
columns?: ResponsiveStyleValue<number | string>;
columns?: ResponsiveStyleValue<number | string> | undefined;
/**
* The default number of columns of the component. This is provided for server-side rendering.
*/
defaultColumns?: number;
defaultColumns?: number | undefined;
/**
* The default height of the component in px. This is provided for server-side rendering.
*/
defaultHeight?: number;
defaultHeight?: number | undefined;
/**
* The default spacing of the component. Like `spacing`, it is a factor of the theme's spacing. This is provided for server-side rendering.
*/
defaultSpacing?: number;
defaultSpacing?: number | undefined;
/**
* Defines the space between children. It is a factor of the theme's spacing.
* @default 1
*/
spacing?: ResponsiveStyleValue<number | string>;
spacing?: ResponsiveStyleValue<number | string> | undefined;
/**
* Allows using sequential order rather than adding to shortest column
* @default false
*/
sequential?: boolean;
sequential?: boolean | undefined;
/**
* Allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
sx?: SxProps<Theme> | undefined;
}

export interface MasonryTypeMap<
Expand Down
6 changes: 3 additions & 3 deletions packages/mui-lab/src/TabPanel/TabPanel.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export interface TabPanelProps extends StandardProps<React.HTMLAttributes<HTMLDi
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<TabPanelClasses>;
classes?: Partial<TabPanelClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
sx?: SxProps<Theme> | undefined;
/**
* The `value` of the corresponding `Tab`. Must use the index of the `Tab` when
* no `value` was passed to `Tab`.
Expand All @@ -26,7 +26,7 @@ export interface TabPanelProps extends StandardProps<React.HTMLAttributes<HTMLDi
* Always keep the children in the DOM.
* @default false
*/
keepMounted?: boolean;
keepMounted?: boolean | undefined;
}

/**
Expand Down
8 changes: 4 additions & 4 deletions packages/mui-lab/src/Timeline/Timeline.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ export interface TimelineProps extends StandardProps<React.ComponentProps<'ul'>>
* The position where the TimelineContent should appear relative to the time axis.
* @default 'right'
*/
position?: 'left' | 'right' | 'alternate' | 'alternate-reverse';
position?: 'left' | 'right' | 'alternate' | 'alternate-reverse' | undefined;
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<TimelineClasses>;
classes?: Partial<TimelineClasses> | undefined;
/**
* className applied to the root element.
*/
className?: string;
className?: string | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
sx?: SxProps<Theme> | undefined;
}
4 changes: 2 additions & 2 deletions packages/mui-lab/src/TimelineConnector/TimelineConnector.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export interface TimelineConnectorProps extends StandardProps<
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<TimelineConnectorClasses>;
classes?: Partial<TimelineConnectorClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
sx?: SxProps<Theme> | undefined;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-lab/src/TimelineContent/TimelineContent.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export interface TimelineContentProps extends StandardProps<TypographyProps> {
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<TimelineContentClasses>;
classes?: Partial<TimelineContentClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
sx?: SxProps<Theme> | undefined;
}

/**
Expand Down
18 changes: 11 additions & 7 deletions packages/mui-lab/src/TimelineDot/TimelineDot.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,28 @@ export interface TimelineDotProps extends StandardProps<React.HTMLAttributes<HTM
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<TimelineDotClasses>;
classes?: Partial<TimelineDotClasses> | undefined;
/**
* The dot can have a different colors.
* @default 'grey'
*/
color?: OverridableStringUnion<
'inherit' | 'grey' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning',
TimelineDotPropsColorOverrides
>;
color?:
| OverridableStringUnion<
'inherit' | 'grey' | 'primary' | 'secondary' | 'error' | 'info' | 'success' | 'warning',
TimelineDotPropsColorOverrides
>
| undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
sx?: SxProps<Theme> | undefined;
/**
* The dot can appear filled or outlined.
* @default 'filled'
*/
variant?: OverridableStringUnion<'filled' | 'outlined', TimelineDotPropsVariantOverrides>;
variant?:
| OverridableStringUnion<'filled' | 'outlined', TimelineDotPropsVariantOverrides>
| undefined;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions packages/mui-lab/src/TimelineItem/TimelineItem.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,19 @@ export interface TimelineItemProps extends StandardProps<React.HTMLAttributes<HT
/**
* The position where the timeline's item should appear.
*/
position?: 'left' | 'right' | 'alternate' | 'alternate-reverse';
position?: 'left' | 'right' | 'alternate' | 'alternate-reverse' | undefined;
/**
* The content of the component.
*/
children?: React.ReactNode;
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<TimelineItemClasses>;
classes?: Partial<TimelineItemClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
sx?: SxProps<Theme> | undefined;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ export interface TimelineOppositeContentProps extends StandardProps<TypographyPr
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<TimelineOppositeContentClasses>;
classes?: Partial<TimelineOppositeContentClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
sx?: SxProps<Theme> | undefined;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-lab/src/TimelineSeparator/TimelineSeparator.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ export interface TimelineSeparatorProps extends StandardProps<
/**
* Override or extend the styles applied to the component.
*/
classes?: Partial<TimelineSeparatorClasses>;
classes?: Partial<TimelineSeparatorClasses> | undefined;
/**
* The system prop that allows defining system overrides as well as additional CSS styles.
*/
sx?: SxProps<Theme>;
sx?: SxProps<Theme> | undefined;
}

/**
Expand Down
Loading
Loading