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

chore(react-utilities): improve Slot signature to be more presentable in Storybook #31636

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bsunderhus
Copy link
Contributor

@bsunderhus bsunderhus commented Jun 10, 2024

Previous Behavior

Slot signature gets broken into its type equivalence by TS compiler (more info #27105 (comment)):

image

New Behavior

Modifies Slot signature to be more presentable on Storybook's docgen extraction.

image

Problems involved with this Solution

We verify if the first generic provided to Slot<T> is a singleton value (a value that is not an union of other values). This PR modifies this signature to be internal to another type (SlotProps), as this type verification is one of the causes of why Slot signature ends up being processed by TS compiler the way it does.

Previously if someone would provide a union we'd have:

image

By moving the singleton verification down to another type (SlotProps) we'll be allowing some types in situations they should probably not be allowed, in this case in particular is not so problematic as we're only allowing null:

image

Related Issue(s)

@fabricteam
Copy link
Collaborator

fabricteam commented Jun 10, 2024

Perf Analysis (@fluentui/react-components)

Scenario Render type Master Ticks PR Ticks Iterations Status
FluentProviderWithTheme virtual-rerender-with-unmount 80 67 10 Possible regression
All results

Scenario Render type Master Ticks PR Ticks Iterations Status
Avatar mount 609 623 5000
Button mount 297 297 5000
Field mount 1152 1126 5000
FluentProvider mount 719 708 5000
FluentProviderWithTheme mount 91 88 10
FluentProviderWithTheme virtual-rerender 34 33 10
FluentProviderWithTheme virtual-rerender-with-unmount 80 67 10 Possible regression
MakeStyles mount 845 846 50000
Persona mount 1728 1747 5000
SpinButton mount 1412 1363 5000
SwatchPicker mount 1524 1505 5000

@fabricteam
Copy link
Collaborator

fabricteam commented Jun 10, 2024

📊 Bundle size report

✅ No changes found

@bsunderhus bsunderhus force-pushed the react-utilities/chore--improve-Storybook-prop-table-for-Slot<T>-type branch from 2cba23e to f9ed3eb Compare June 10, 2024 11:13
@bsunderhus bsunderhus changed the title chore: improve Slot signature to be more presentable in Storybook chore(react-utilities): improve Slot signature to be more presentable in Storybook Jun 10, 2024
@bsunderhus bsunderhus requested a review from behowell June 12, 2024 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docs]: improve Storybook prop table for Slot<T> type
2 participants