[code-infra] Upgrade react-docgen to v8#47685
Conversation
Netlify deploy previewhttps://deploy-preview-47685--material-ui.netlify.app/ Bundle size report
|
|
@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 |
| 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 |
There was a problem hiding this comment.
So it went from first to last definition wins?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
interface A extends B {}feels similar to
B & Ato me, as in A's props should win over Bs, but that isn't how this code interpretes it?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
|
Took the liberty of removing a few more |
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? |
…eclarations The `getSymbolDocumentation` function was introduced in mui#47685 to handle JSDoc merging across multiple TypeScript declarations. However, it unconditionally joined all unique JSDoc comments when a symbol had multiple declarations, which produced duplicated descriptions in the generated propTypes for interface declaration merging and module augmentation scenarios. TypeScript treats JSDoc differently depending on how declarations combine: - Intersection types (type C = A & B): all constituent JSDoc are merged - Interface extends (interface Z extends X, Y): first parent's JSDoc wins - Interface override (interface W extends X { prop }): the override's JSDoc wins - Declaration merging / module augmentation: last declaration's JSDoc wins The previous implementation treated all multi-declaration cases as intersections, concatenating distinct comments. This caused issues in downstream repos (e.g. mui-x) where module augmentation is used to extend interface props — the original and augmented JSDoc would both appear in the generated propTypes output. The fix now uses `parentType.isIntersection()` to distinguish intersection types (where merging is correct) from declaration merging (where the last declaration should win), matching TypeScript's own behavior. Added test cases for all four JSDoc resolution scenarios: - jsdoc-intersection: verifies both descriptions are merged - jsdoc-interface-extends: verifies first parent's description wins - jsdoc-interface-override: verifies override description wins - declaration-merging: verifies last (augmented) description wins
…eclarations The `getSymbolDocumentation` function was introduced in mui#47685 to handle JSDoc merging across multiple TypeScript declarations. However, it unconditionally joined all unique JSDoc comments when a symbol had multiple declarations, which produced duplicated descriptions in the generated propTypes for interface declaration merging and module augmentation scenarios. TypeScript treats JSDoc differently depending on how declarations combine: - Intersection types (type C = A & B): all constituent JSDoc are merged - Interface extends (interface Z extends X, Y): first parent's JSDoc wins - Interface override (interface W extends X { prop }): the override's JSDoc wins - Declaration merging / module augmentation: last declaration's JSDoc wins The previous implementation treated all multi-declaration cases as intersections, concatenating distinct comments. This caused issues in downstream repos (e.g. mui-x) where module augmentation is used to extend interface props — the original and augmented JSDoc would both appear in the generated propTypes output. The fix now uses `parentType.isIntersection()` to distinguish intersection types (where merging is correct) from declaration merging (where the last declaration should win), matching TypeScript's own behavior. Added test cases for all four JSDoc resolution scenarios: - jsdoc-intersection: verifies both descriptions are merged - jsdoc-interface-extends: verifies first parent's description wins - jsdoc-interface-override: verifies override description wins - declaration-merging: verifies last (augmented) description wins
…eclarations The `getSymbolDocumentation` function was introduced in mui#47685 to handle JSDoc merging across multiple TypeScript declarations. However, it unconditionally joined all unique JSDoc comments when a symbol had multiple declarations, which produced duplicated descriptions in the generated propTypes for interface declaration merging and module augmentation scenarios. TypeScript treats JSDoc differently depending on how declarations combine: - Intersection types (type C = A & B): all constituent JSDoc are merged - Interface extends (interface Z extends X, Y): first parent's JSDoc wins - Interface override (interface W extends X { prop }): the override's JSDoc wins - Declaration merging / module augmentation: last declaration's JSDoc wins The previous implementation treated all multi-declaration cases as intersections, concatenating distinct comments. This caused issues in downstream repos (e.g. mui-x) where module augmentation is used to extend interface props — the original and augmented JSDoc would both appear in the generated propTypes output. The fix now uses `parentType.isIntersection()` to distinguish intersection types (where merging is correct) from declaration merging (where the last declaration should win), matching TypeScript's own behavior. Added test cases for all four JSDoc resolution scenarios: - jsdoc-intersection: verifies both descriptions are merged - jsdoc-interface-extends: verifies first parent's description wins - jsdoc-interface-override: verifies override description wins - declaration-merging: verifies last (augmented) description wins
…eclarations The `getSymbolDocumentation` function was introduced in mui#47685 to handle JSDoc merging across multiple TypeScript declarations. However, it unconditionally joined all unique JSDoc comments when a symbol had multiple declarations, which produced duplicated descriptions in the generated propTypes for interface declaration merging, module augmentation, and intersection type scenarios. The previous implementation treated all multi-declaration cases as intersections and concatenated distinct comments. This caused issues in downstream repos (e.g. mui-x) where: - Module augmentation extends interface props (e.g. BarPlotProps onItemClick) - Intersection types combine types with overridden JSDoc (e.g. autoFocus in MultiInputDateRangeField where the field-specific description should replace the base HTML input description) The fix uses a simple "last declaration wins" rule for all cases with multiple declarations, consistent with `squashPropTypeDefinitions` which already uses the same approach. This correctly handles: - Declaration merging / module augmentation: augmentation wins - Intersection types: last constituent wins - Interface extends / override: override wins (single declaration) Added test cases for all four JSDoc resolution scenarios: - jsdoc-intersection: verifies last constituent's description wins - jsdoc-interface-extends: verifies first parent's description wins - jsdoc-interface-override: verifies override description wins - declaration-merging: verifies last (augmented) description wins This change has no affect on this repo and affects around 7 api/proptypes generation in X repo.
…eclarations The `getSymbolDocumentation` function was introduced in mui#47685 to handle JSDoc merging across multiple TypeScript declarations. However, it unconditionally joined all unique JSDoc comments when a symbol had multiple declarations, which produced duplicated descriptions in the generated propTypes for interface declaration merging, module augmentation, and intersection type scenarios. The previous implementation treated all multi-declaration cases as intersections and concatenated distinct comments. This caused issues in downstream repos (e.g. mui-x) where: - Module augmentation extends interface props (e.g. BarPlotProps onItemClick) - Intersection types combine types with overridden JSDoc (e.g. autoFocus in MultiInputDateRangeField where the field-specific description should replace the base HTML input description) The fix uses a simple "last declaration wins" rule for all cases with multiple declarations, consistent with `squashPropTypeDefinitions` which already uses the same approach. This correctly handles: - Declaration merging / module augmentation: augmentation wins - Intersection types: last constituent wins - Interface extends / override: override wins (single declaration) Added test cases for all four JSDoc resolution scenarios: - jsdoc-intersection: verifies last constituent's description wins - jsdoc-interface-extends: verifies first parent's description wins - jsdoc-interface-override: verifies override description wins - declaration-merging: verifies last (augmented) description wins This change has no effect on this repo and affects around 7 api/proptypes generation in X repo.
…eclarations The `getSymbolDocumentation` function was introduced in mui#47685 to handle JSDoc merging across multiple TypeScript declarations. However, it unconditionally joined all unique JSDoc comments when a symbol had multiple declarations, which produced duplicated descriptions in the generated propTypes for interface declaration merging, module augmentation, and intersection type scenarios. The previous implementation treated all multi-declaration cases as intersections and concatenated distinct comments. This caused issues in downstream repos (e.g. mui-x) where: - Module augmentation extends interface props (e.g. BarPlotProps onItemClick) - Intersection types combine types with overridden JSDoc (e.g. autoFocus in MultiInputDateRangeField where the field-specific description should replace the base HTML input description) The fix uses a simple "last declaration wins" rule for all cases with multiple declarations, consistent with `squashPropTypeDefinitions` which already uses the same approach. This correctly handles: - Declaration merging / module augmentation: augmentation wins - Intersection types: last constituent wins - Interface extends / override: override wins (single declaration) Added test cases for all four JSDoc resolution scenarios: - jsdoc-intersection: verifies last constituent's description wins - jsdoc-interface-extends: verifies first parent's description wins - jsdoc-interface-override: verifies override description wins - declaration-merging: verifies last (augmented) description wins This change has no effect on this repo and affects around 7 api/proptypes generation in X repo.
`getSymbolDocumentation` (introduced in mui#47685) concatenated JSDoc from all declarations when a symbol had multiple (intersection, declaration merging, module augmentation). This produced duplicated descriptions in generated propTypes. Fix: use "last declaration wins" for all multi-declaration cases, consistent with `squashPropTypeDefinitions`. Added tests for intersection, interface extends, interface override, and declaration merging scenarios. This change has no effect on this repo and affects around 7 api/proptypes generation in X repo.
`getSymbolDocumentation` (introduced in mui#47685) concatenated JSDoc from all declarations when a symbol had multiple (intersection, declaration merging, module augmentation). This produced duplicated descriptions in generated propTypes. Fix: use "last declaration wins" for all multi-declaration cases, consistent with `squashPropTypeDefinitions`. Added tests for intersection, interface extends, interface override, and declaration merging scenarios. This change has no effect on this repo and affects around 7 api/proptypes generation in X repo.
`getSymbolDocumentation` (introduced in mui#47685) concatenated JSDoc from all declarations when a symbol had multiple (intersection, declaration merging, module augmentation). This produced duplicated descriptions in generated propTypes. Fix: use "last declaration wins" for all multi-declaration cases, consistent with `squashPropTypeDefinitions`. Added tests for intersection, interface extends, interface override, and declaration merging scenarios. This change has no effect on this repo and affects around 7 api/proptypes generation in X repo.
`getSymbolDocumentation` (introduced in mui#47685) concatenated JSDoc from all declarations when a symbol had multiple (intersection, declaration merging, module augmentation). This produced duplicated descriptions in generated propTypes. Fix: use "last declaration wins" for all multi-declaration cases, consistent with `squashPropTypeDefinitions`. Added tests for intersection, interface extends, interface override, and declaration merging scenarios. This change has no effect on this repo and affects around 7 api/proptypes generation in X repo.
`getSymbolDocumentation` (introduced in mui#47685) concatenated JSDoc from all declarations when a symbol had multiple (intersection, declaration merging, module augmentation). This produced duplicated descriptions in generated propTypes. Fix: use "last declaration wins" for all multi-declaration cases, consistent with `squashPropTypeDefinitions`. Added tests for intersection, interface extends, interface override, and declaration merging scenarios. This change has no effect on this repo and affects around 7 api/proptypes generation in X repo.
`getSymbolDocumentation` (introduced in mui#47685) concatenated JSDoc from all declarations when a symbol had multiple (intersection, declaration merging, module augmentation). This produced duplicated descriptions in generated propTypes. Fix: use "last declaration wins" for all multi-declaration cases, consistent with `squashPropTypeDefinitions`. Added tests for intersection, interface extends, interface override, and declaration merging scenarios. This change has no effect on this repo and affects around 7 api/proptypes generation in X repo.
prop?.that are needed, we weren't taking that they were undefined before, current types should be better as they come from the libButtonBase.d.ts): Added dynamic Omit to exclude props that child types redefinePaper.d.ts): Same pattern to preventchildrenandsxduplication in Accordion, AppBar, etc.List.d.ts): Same pattern to preventchildrenduplication in MenuListstyles/index.d.ts): Removed JSDoc to preventclassesduplicationtransitions/transition.ts): DefinedaddEndListenerlocally with JSDoc to avoid duplication from external react-transition-group typesvariantfrom BaseSelectProps (moved JSDoc to OutlinedSelectProps only)'defaultValue' | 'sx'to Omit in all variant interfaceschildrenprop since it was no longer inheritedSwipeableDrawerSlotsextendDrawerSlotsand used singleCreateSlotsAndSlotPropsto avoid duplicate slots/slotProps JSDocX changes mui/mui-x#21155