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

[Select] Revert "Update renderValue prop's TypeScript type (#34177)" #35733

Merged
merged 1 commit into from
Jan 9, 2023

Conversation

michaldudak
Copy link
Member

This reverts commit fea32da (PR #34177).

Fixes #35728 but reopens #34083.

The #34177 PR can be reapplied in v6 as it causes a breaking change in type definitions.

@michaldudak michaldudak added component: select This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material labels Jan 5, 2023
@michaldudak michaldudak requested a review from mnajdova January 5, 2023 11:41
@mui-bot
Copy link

mui-bot commented Jan 5, 2023

Messages
📖 Netlify deploy preview: https://deploy-preview-35733--material-ui.netlify.app/

No bundle size changes

Generated by 🚫 dangerJS against 0f1a159

@jonesmac
Copy link

jonesmac commented Jan 5, 2023

Thanks @michaldudak. I took a stab at trying to fix the issue as well and here's where I ended up.

I fully understand the value adding stronger types may have added, but I don't know if it belongs in the core library. Anytime you try to make interface properties change their type based off sibling interface properties (i.e. displayEmpty affecting renderValue) that feels best served as a runtime check OR splitting the interface to break the dependency.

For instance:

interface DisplayNotEmpty<T> {
      displayEmpty?: false;
      multiple?: boolean;
      renderValue?: (value: T) => React.ReactNode;
}

interface DisplayEmpty<T> {
      displayEmpty?: true;
      multiple?: false;
      renderValue?: (value: T | '') => React.ReactNode;
}

interface DisplayEmptyMultiple<T> {
      displayEmpty?: true;
      multiple?: true;
      renderValue?: (value: T) => React.ReactNode;
}

export interface SelectProps<T> extends CommonProps<T> {
  renderType: DisplayNotEmpty<T> | DisplayEmpty<T> | DisplayEmptyMultiple<T>
}

Allows for:

interface SelectExProps extends SelectProps<number> {
  
}

Example here - https://codesandbox.io/s/awesome-dewdney-r0vrpk?file=/src/App.tsx

@ZeeshanTamboli
Copy link
Member

@michaldudak Thanks for the quick PR. I didn't anticipate this would cause an issue in #34177 .

Copy link
Member

@mnajdova mnajdova left a comment

Choose a reason for hiding this comment

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

Thanks. Yeah, I had a feeling #34177 may break some users of the library. Lesson learned for us :)

@michaldudak michaldudak merged commit d688650 into mui:master Jan 9, 2023
@michaldudak michaldudak deleted the revert-34177 branch January 9, 2023 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: select This is the name of the generic UI component, not the React module! package: material-ui Specific to @mui/material
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Select](typescript) v5.11.3 patch broke extending and using SelectProps
5 participants