Skip to content

Commit fba5135

Browse files
authored
[core] Add ref type to every component (#17286)
1 parent 514319e commit fba5135

File tree

7 files changed

+10
-26
lines changed

7 files changed

+10
-26
lines changed

packages/material-ui-lab/src/SpeedDial/SpeedDial.d.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ import { TransitionHandlerProps } from '@material-ui/core/transitions';
77
export interface SpeedDialProps
88
extends StandardProps<
99
React.HTMLAttributes<HTMLDivElement> & Partial<TransitionHandlerProps>,
10-
SpeedDialClassKey,
11-
never,
12-
false
10+
SpeedDialClassKey
1311
> {
1412
ariaLabel: string;
1513
ButtonProps?: Partial<ButtonProps>;

packages/material-ui-lab/src/SpeedDialAction/SpeedDialAction.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { ButtonProps } from '@material-ui/core/Button';
44
import { TooltipProps } from '@material-ui/core/Tooltip';
55

66
export interface SpeedDialActionProps
7-
extends StandardProps<Partial<TooltipProps>, SpeedDialActionClassKey, never, false> {
7+
extends StandardProps<Partial<TooltipProps>, SpeedDialActionClassKey> {
88
ButtonProps?: Partial<ButtonProps>;
99
delay?: number;
1010
icon: React.ReactNode;

packages/material-ui-lab/src/SpeedDialIcon/SpeedDialIcon.d.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,7 @@ import * as React from 'react';
22
import { StandardProps } from '@material-ui/core';
33

44
export interface SpeedDialIconProps
5-
extends StandardProps<
6-
React.HTMLAttributes<HTMLSpanElement>,
7-
SpeedDialIconClassKey,
8-
never,
9-
false
10-
> {
5+
extends StandardProps<React.HTMLAttributes<HTMLSpanElement>, SpeedDialIconClassKey> {
116
icon?: React.ReactNode;
127
openIcon?: React.ReactNode;
138
}

packages/material-ui-lab/src/ToggleButtonGroup/ToggleButtonGroup.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@ export interface ToggleButtonGroupProps
66
extends StandardProps<
77
React.HTMLAttributes<HTMLDivElement>,
88
ToggleButtonGroupClassKey,
9-
'onChange',
10-
false
9+
'onChange'
1110
> {
1211
selected?: boolean;
1312
exclusive?: boolean;

packages/material-ui/src/ListItemAvatar/ListItemAvatar.d.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { StandardProps } from '..';
22

3-
export interface ListItemAvatarProps
4-
extends StandardProps<{}, ListItemAvatarClassKey, never, false> {}
3+
export interface ListItemAvatarProps extends StandardProps<{}, ListItemAvatarClassKey> {}
54

65
export type ListItemAvatarClassKey = 'root' | 'icon';
76

packages/material-ui/src/Tooltip/Tooltip.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { TransitionProps } from '../transitions/transition';
44
import { PopperProps } from '../Popper/Popper';
55

66
export interface TooltipProps
7-
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, TooltipClassKey, 'title', false> {
7+
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, TooltipClassKey, 'title'> {
88
children: React.ReactElement;
99
disableFocusListener?: boolean;
1010
disableHoverListener?: boolean;

packages/material-ui/src/index.d.ts

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,14 @@ export { Omit };
1414
* certain `classes`, on which one can also set a top-level `className` and inline
1515
* `style`.
1616
*/
17-
export type StandardProps<
17+
export type StandardProps<C, ClassKey extends string, Removals extends keyof C = never> = Omit<
1818
C,
19-
ClassKey extends string,
20-
Removals extends keyof C = never,
21-
AcceptsRef = true
22-
> = Omit<C, 'classes' | Removals> &
19+
'classes' | Removals
20+
> &
2321
StyledComponentProps<ClassKey> & {
2422
className?: string;
23+
ref?: C extends { ref?: infer RefType } ? RefType : React.Ref<unknown>;
2524
style?: React.CSSProperties;
26-
} & {
27-
ref?: AcceptsRef extends true
28-
? C extends { ref?: infer RefType }
29-
? RefType
30-
: React.Ref<unknown>
31-
: never;
3225
};
3326

3427
export type PaletteType = 'light' | 'dark';

0 commit comments

Comments
 (0)