Skip to content

Commit

Permalink
Fix issues that appeared with TS 4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Aug 30, 2022
1 parent 992421d commit 6ca480b
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions docs/data/base/components/select/UnstyledSelectSimple.tsx
Expand Up @@ -130,7 +130,7 @@ const StyledPopper = styled(PopperUnstyled)`
z-index: 1;
`;

const CustomSelect = React.forwardRef(function CustomSelect<TValue>(
const CustomSelect = React.forwardRef(function CustomSelect<TValue extends {}>(
props: SelectUnstyledProps<TValue>,
ref: React.ForwardedRef<HTMLButtonElement>,
) {
Expand All @@ -142,7 +142,7 @@ const CustomSelect = React.forwardRef(function CustomSelect<TValue>(
};

return <SelectUnstyled {...props} ref={ref} components={components} />;
}) as <TValue>(
}) as <TValue extends {}>(
props: SelectUnstyledProps<TValue> & React.RefAttributes<HTMLButtonElement>,
) => JSX.Element;

Expand Down
Expand Up @@ -27,12 +27,12 @@ const MultiSelectUnstyledComponentsPropsOverridesTest = (
/>
);

function CustomRoot<TValue>(props: MultiSelectUnstyledRootSlotProps<TValue>) {
function CustomRoot<TValue extends {}>(props: MultiSelectUnstyledRootSlotProps<TValue>) {
const { ownerState, ...other } = props;
return <div {...other} />;
}

function CustomPopper<TValue>(props: MultiSelectUnstyledPopperSlotProps<TValue>) {
function CustomPopper<TValue extends {}>(props: MultiSelectUnstyledPopperSlotProps<TValue>) {
const { ownerState, ...other } = props;
return <PopperUnstyled {...other} />;
}
Expand Down
Expand Up @@ -75,7 +75,7 @@ function useUtilityClasses(ownerState: MultiSelectUnstyledOwnerState<any>) {
*
* - [MultiSelectUnstyled API](https://mui.com/base/api/multi-select-unstyled/)
*/
const MultiSelectUnstyled = React.forwardRef(function MultiSelectUnstyled<TValue>(
const MultiSelectUnstyled = React.forwardRef(function MultiSelectUnstyled<TValue extends {}>(
props: MultiSelectUnstyledProps<TValue>,
forwardedRef: React.ForwardedRef<any>,
) {
Expand Down
Expand Up @@ -112,30 +112,31 @@ export interface MultiSelectUnstyledType {
propTypes?: any;
}

export interface MultiSelectUnstyledOwnerState<TValue> extends MultiSelectUnstyledProps<TValue> {
export interface MultiSelectUnstyledOwnerState<TValue extends {}>
extends MultiSelectUnstyledProps<TValue> {
active: boolean;
disabled: boolean;
open: boolean;
focusVisible: boolean;
}

export type MultiSelectUnstyledRootSlotProps<TValue> = Simplify<
export type MultiSelectUnstyledRootSlotProps<TValue extends {}> = Simplify<
UseSelectButtonSlotProps & {
className?: string;
children?: React.ReactNode;
ownerState: MultiSelectUnstyledOwnerState<TValue>;
}
>;

export type MultiSelectUnstyledListboxSlotProps<TValue> = Simplify<
export type MultiSelectUnstyledListboxSlotProps<TValue extends {}> = Simplify<
UseSelectListboxSlotProps & {
className?: string;
children?: React.ReactNode;
ownerState: MultiSelectUnstyledOwnerState<TValue>;
}
>;

export type MultiSelectUnstyledPopperSlotProps<TValue> = {
export type MultiSelectUnstyledPopperSlotProps<TValue extends {}> = {
anchorEl: PopperUnstyledProps['anchorEl'];
children?: PopperUnstyledProps['children'];
className?: string;
Expand Down
4 changes: 2 additions & 2 deletions packages/mui-base/src/SelectUnstyled/SelectUnstyled.spec.tsx
Expand Up @@ -27,12 +27,12 @@ const SelectUnstyledComponentsPropsOverridesTest = (
/>
);

function CustomRoot<TValue>(props: SelectUnstyledRootSlotProps<TValue>) {
function CustomRoot<TValue extends {}>(props: SelectUnstyledRootSlotProps<TValue>) {
const { ownerState, ...other } = props;
return <div {...other} />;
}

function CustomPopper<TValue>(props: SelectUnstyledPopperSlotProps<TValue>) {
function CustomPopper<TValue extends {}>(props: SelectUnstyledPopperSlotProps<TValue>) {
const { ownerState, ...other } = props;
return <PopperUnstyled {...other} />;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/SelectUnstyled/SelectUnstyled.tsx
Expand Up @@ -67,7 +67,7 @@ function useUtilityClasses(ownerState: SelectUnstyledOwnerState<any>) {
*
* - [SelectUnstyled API](https://mui.com/base/api/select-unstyled/)
*/
const SelectUnstyled = React.forwardRef(function SelectUnstyled<TValue>(
const SelectUnstyled = React.forwardRef(function SelectUnstyled<TValue extends {}>(
props: SelectUnstyledProps<TValue>,
forwardedRef: React.ForwardedRef<any>,
) {
Expand Down
9 changes: 5 additions & 4 deletions packages/mui-base/src/SelectUnstyled/SelectUnstyled.types.ts
Expand Up @@ -150,30 +150,31 @@ export interface SelectUnstyledType {
propTypes?: any;
}

export interface SelectUnstyledOwnerState<TValue> extends SelectUnstyledOwnProps<TValue> {
export interface SelectUnstyledOwnerState<TValue extends {}>
extends SelectUnstyledOwnProps<TValue> {
active: boolean;
disabled: boolean;
focusVisible: boolean;
open: boolean;
}

export type SelectUnstyledRootSlotProps<TValue> = Simplify<
export type SelectUnstyledRootSlotProps<TValue extends {}> = Simplify<
UseSelectButtonSlotProps & {
className?: string;
children?: React.ReactNode;
ownerState: SelectUnstyledOwnerState<TValue>;
}
>;

export type SelectUnstyledListboxSlotProps<TValue> = Simplify<
export type SelectUnstyledListboxSlotProps<TValue extends {}> = Simplify<
UseSelectListboxSlotProps & {
className?: string;
children?: React.ReactNode;
ownerState: SelectUnstyledOwnerState<TValue>;
}
>;

export type SelectUnstyledPopperSlotProps<TValue> = {
export type SelectUnstyledPopperSlotProps<TValue extends {}> = {
anchorEl: PopperUnstyledProps['anchorEl'];
children?: PopperUnstyledProps['children'];
className?: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/mui-base/src/utils/useSlotProps.test.tsx
Expand Up @@ -11,7 +11,7 @@ function callUseSlotProps<
ElementType extends React.ElementType,
SlotProps,
ExternalForwardedProps,
ExternalSlotProps,
ExternalSlotProps extends Record<string, unknown>,
AdditionalProps,
OwnerState,
>(
Expand Down

0 comments on commit 6ca480b

Please sign in to comment.