Skip to content
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

[core] Add ref type to every component #17286

Merged
merged 1 commit into from
Sep 3, 2019
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
4 changes: 1 addition & 3 deletions packages/material-ui-lab/src/SpeedDial/SpeedDial.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import { TransitionHandlerProps } from '@material-ui/core/transitions';
export interface SpeedDialProps
extends StandardProps<
React.HTMLAttributes<HTMLDivElement> & Partial<TransitionHandlerProps>,
SpeedDialClassKey,
never,
false
SpeedDialClassKey
> {
ariaLabel: string;
ButtonProps?: Partial<ButtonProps>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { ButtonProps } from '@material-ui/core/Button';
import { TooltipProps } from '@material-ui/core/Tooltip';

export interface SpeedDialActionProps
extends StandardProps<Partial<TooltipProps>, SpeedDialActionClassKey, never, false> {
extends StandardProps<Partial<TooltipProps>, SpeedDialActionClassKey> {
ButtonProps?: Partial<ButtonProps>;
delay?: number;
icon: React.ReactNode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ import * as React from 'react';
import { StandardProps } from '@material-ui/core';

export interface SpeedDialIconProps
extends StandardProps<
React.HTMLAttributes<HTMLSpanElement>,
SpeedDialIconClassKey,
never,
false
> {
extends StandardProps<React.HTMLAttributes<HTMLSpanElement>, SpeedDialIconClassKey> {
icon?: React.ReactNode;
openIcon?: React.ReactNode;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ export interface ToggleButtonGroupProps
extends StandardProps<
React.HTMLAttributes<HTMLDivElement>,
ToggleButtonGroupClassKey,
'onChange',
false
'onChange'
> {
selected?: boolean;
exclusive?: boolean;
Expand Down
3 changes: 1 addition & 2 deletions packages/material-ui/src/ListItemAvatar/ListItemAvatar.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { StandardProps } from '..';

export interface ListItemAvatarProps
extends StandardProps<{}, ListItemAvatarClassKey, never, false> {}
export interface ListItemAvatarProps extends StandardProps<{}, ListItemAvatarClassKey> {}

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

Expand Down
2 changes: 1 addition & 1 deletion packages/material-ui/src/Tooltip/Tooltip.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { TransitionProps } from '../transitions/transition';
import { PopperProps } from '../Popper/Popper';

export interface TooltipProps
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, TooltipClassKey, 'title', false> {
extends StandardProps<React.HTMLAttributes<HTMLDivElement>, TooltipClassKey, 'title'> {
children: React.ReactElement;
disableFocusListener?: boolean;
disableHoverListener?: boolean;
Expand Down
15 changes: 4 additions & 11 deletions packages/material-ui/src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,14 @@ export { Omit };
* certain `classes`, on which one can also set a top-level `className` and inline
* `style`.
*/
export type StandardProps<
export type StandardProps<C, ClassKey extends string, Removals extends keyof C = never> = Omit<
C,
ClassKey extends string,
Removals extends keyof C = never,
AcceptsRef = true
> = Omit<C, 'classes' | Removals> &
'classes' | Removals
> &
StyledComponentProps<ClassKey> & {
className?: string;
ref?: C extends { ref?: infer RefType } ? RefType : React.Ref<unknown>;
style?: React.CSSProperties;
} & {
ref?: AcceptsRef extends true
? C extends { ref?: infer RefType }
? RefType
: React.Ref<unknown>
: never;
};

export type PaletteType = 'light' | 'dark';
Expand Down