Skip to content

[Switch] inputProps can take additional props #18902

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
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
7 changes: 6 additions & 1 deletion packages/material-ui/src/internal/SwitchBase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export interface SwitchBaseProps
disabled?: boolean;
disableRipple?: boolean;
icon: React.ReactNode;
inputProps?: React.InputHTMLAttributes<HTMLInputElement>;
inputProps?: SwitchBaseComponentProps;
inputRef?: React.Ref<any>;
name?: string;
onChange?: (event: React.ChangeEvent<HTMLInputElement>, checked: boolean) => void;
Expand All @@ -21,6 +21,11 @@ export interface SwitchBaseProps
value?: unknown;
}

export interface SwitchBaseComponentProps extends React.HTMLAttributes<HTMLInputElement> {
// Accommodate arbitrary additional props coming from the `inputProps` prop
[arbitrary: string]: any;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that this will not catch excess props that are actually wrong (such as those from typos or accidental wrong names.

}

export type SwitchBaseClassKey = 'root' | 'checked' | 'disabled' | 'input';

declare const SwitchBase: React.ComponentType<SwitchBaseProps>;
Expand Down