Skip to content

Conversation

@JCQuintas
Copy link
Member

@JCQuintas JCQuintas commented Jan 26, 2026

  • Remove unnecessary types
  • Small fixes for changes in v6, v7 and v8
  • Should support newer typescript
  • Most stuff done by claude
  • There is a lot of prop?. that are needed, we weren't taking that they were undefined before, current types should be better as they come from the lib
  • There is also an issue where the actual typedocs are duplicated if the props of an object are declared multiple times. hover on the prop value
    • This PR prevents it by displaying that in the propTypes/docs, so our devs are aware of it. A side-effect is that I had to "clean" some of the types in the code.
      1. ExtendButtonBaseTypeMap (ButtonBase.d.ts): Added dynamic Omit to exclude props that child types redefine
      2. ExtendPaperTypeMap (Paper.d.ts): Same pattern to prevent children and sx duplication in Accordion, AppBar, etc.
      3. ExtendListTypeMap (List.d.ts): Same pattern to prevent children duplication in MenuList
      4. StyledComponentProps (styles/index.d.ts): Removed JSDoc to prevent classes duplication
      5. TransitionProps (transitions/transition.ts): Defined addEndListener locally with JSDoc to avoid duplication from external react-transition-group types
      6. Select.d.ts:
      • Removed variant from BaseSelectProps (moved JSDoc to OutlinedSelectProps only)
      • Added 'defaultValue' | 'sx' to Omit in all variant interfaces
      1. TextField.d.ts: Restructured variant interfaces to use indexed access types for slots/slotProps without inheriting duplicate JSDoc
      2. AccordionSummary.d.ts: Added JSDoc to children prop since it was no longer inherited
      3. SwipeableDrawer.d.ts: Made SwipeableDrawerSlots extend DrawerSlots and used single CreateSlotsAndSlotProps to avoid duplicate slots/slotProps JSDoc

X changes mui/mui-x#21155

@JCQuintas JCQuintas self-assigned this Jan 26, 2026
@JCQuintas JCQuintas added type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature. scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). labels Jan 26, 2026
@mui-bot
Copy link

mui-bot commented Jan 26, 2026

Netlify deploy preview

https://deploy-preview-47685--material-ui.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/material 0B(0.00%) 0B(0.00%)
@mui/lab 0B(0.00%) 0B(0.00%)
@mui/system 0B(0.00%) 0B(0.00%)
@mui/utils 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against 0145c29

@JCQuintas JCQuintas marked this pull request as ready for review January 27, 2026 20:57
@JCQuintas JCQuintas requested a review from a team January 27, 2026 20:57
@JCQuintas
Copy link
Member Author

@mui/infra This is currently working, we might want to divide some of the changes to isolate them, as I took some liberty in the path I took.

I want to hear your opinion on this though, before I go further.

My main motivation was to fix an issue with satisfies usage in X 🫠

distinctDefinitions.set(definition.$$id, definition);
}
// Always update so that the last definition's jsDoc wins
// This ensures that when types are intersected (A & B), the last type's documentation is used
Copy link
Member

Choose a reason for hiding this comment

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

So it went from first to last definition wins?

Copy link
Member Author

Choose a reason for hiding this comment

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

Pretty much

Copy link
Member Author

Choose a reason for hiding this comment

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

Reasoning was more that usually we have

interface A extends B {} which is similar to A & B. It felt a bit arbitrary that the first wins, which would prevent some overriding.

Ideally the best way is to Omit<A, keyof B> & B though

Copy link
Member

Choose a reason for hiding this comment

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

interface A extends B {}

feels similar to

B & A

to me, as in A's props should win over Bs, but that isn't how this code interpretes it?

Copy link
Member Author

Choose a reason for hiding this comment

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

True, A should win in the first, but B should in the second. 🫠

I checked it on the playground

Inheritance picks the first time the prop appears 🙃
If you override it, then it ignores any previous declaration.

Intersection merges all declarations together.

Copy link
Member

@Janpot Janpot Jan 28, 2026

Choose a reason for hiding this comment

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

I think ideally we take interface behavior, because that can't simply be altered to fix the comment. i.e.

interface X extends Y, Z {
  /** foo */
  prop: number
}

we can easily move Y and Z around, but we can't really reorder X. even though, if one comment should win, it's probably X here.

For types, we can freely change the order, so it doesn't really matter what we do in terms of "first wins" or "last wins", we can pick what interfaces do and adjust order where needed.

Instead of adding more Omit, maybe it's a matter of reordering the types in the intersection?

Copy link
Member Author

Choose a reason for hiding this comment

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

I've reworked it a bit to follow typescript, which required less changes in the end :)
Divided them into commits for each component, each with a vague-ish description of the reason 😆

In a few cases it still made sense to add Omit, else the types (when viewed by the user in a code editor) would still be merged/messy.

@Janpot
Copy link
Member

Janpot commented Jan 28, 2026

Took the liberty of removing a few more as any

@Janpot
Copy link
Member

Janpot commented Jan 28, 2026

Added dynamic Omit to exclude props that child types redefine

To me, the intuitive thing to do is that the comment on the prop of the overwrite wins, if there is one. Not sure if that's hard todo or not, but with that logic, do we really need to exclude props?

return declarationsWithComments[0].comment;
}

// Multiple declarations with comments - this is the intersection case (type C = A & B)
Copy link
Member

@Janpot Janpot Jan 29, 2026

Choose a reason for hiding this comment

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

So that means if you change an interface to a type or vice-versa, the extracted comments suddenly can look different?

interface A {
  /** foo */
  prop: Prop
}

interface B {
  /** bar */
  prop: Prop
}

type X = A & B & {
  /** baz */
  prop: Prop
}
interface C extends B, A {
  /** baz */
  prop: Prop
}

type X = C

So these wouldn't produce the same output in the proptypes, right? There seems to be an open issue about this microsoft/TypeScript#30901. Your stance is to try emulate intellisense as closely as possible? I hate this behavior, but it also kind of makes sense to make sure the docs and the intellisense in vscode look the same. Maybe link to that open issue so we can periodically check if it ever gets fixed.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, changing them could look different, which is the behaviour of the intellisense as you mentioned: https://www.typescriptlang.org/play/?#code/JYOwLgpgTgZghgYwgAgILIN4ChnIPQBUByMA9qcgXjsgA5Sm0BcyIArgLYBG0WAvliyhIsRCgBCmGoWJc4UStVz1GLdt14CsYAJ60UADWQBeNMgBkySZey4ZyOQC9FNFc1aceUfoOHR4SMgAwsgQAB6QIAAmAM5WADRmtvhEDnDOVK4M7upePtp6KACaJsGCCKQgMWDIYSxGpsnK2SwAjD4VVTU6LCWNNM2qyABM-EA

I find the internal behaviour of intellisense weird too, but I think it is sensible that we emulate what the users would actually see in the interface in order to better control it.

Personally I don't look at the libraries docs most of the time. I'm reading the types documentation in either the UI or the declarations, so this is technically a "bugfix" for me 😆

I'll mention the issue in code

@Janpot Janpot requested a review from siriwatknp January 29, 2026 10:53
Copy link
Member

@Janpot Janpot left a comment

Choose a reason for hiding this comment

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

Looks good to me, adding @siriwatknp for a review

Did you test how these changes affect X

@JCQuintas
Copy link
Member Author

Looks good to me, adding @siriwatknp for a review

Did you test how these changes affect X

I did, and they will affect X quite a bit, I was waiting for a clearer direction before opening the PR, I'll link it here when it is done

@JCQuintas
Copy link
Member Author

X changes mui/mui-x#21155

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: code-infra Involves the code-infra product (https://www.notion.so/mui-org/5562c14178aa42af97bc1fa5114000cd). type: enhancement It’s an improvement, but we can’t make up our mind whether it's a bug fix or a new feature.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants