diff --git a/.changeset/proud-hornets-itch.md b/.changeset/proud-hornets-itch.md new file mode 100644 index 00000000000..d1be903eee7 --- /dev/null +++ b/.changeset/proud-hornets-itch.md @@ -0,0 +1,5 @@ +--- +'@itwin/itwinui-react': patch +--- + +Component `displayName`s have been eliminiated from the prod build. diff --git a/packages/itwinui-react/src/core/Alert/Alert.tsx b/packages/itwinui-react/src/core/Alert/Alert.tsx index 66ff9a87937..db65cf31d39 100644 --- a/packages/itwinui-react/src/core/Alert/Alert.tsx +++ b/packages/itwinui-react/src/core/Alert/Alert.tsx @@ -75,7 +75,9 @@ const AlertComponent = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', AlertOwnProps & AlertLegacyProps>; -AlertComponent.displayName = 'Alert'; +if (process.env.NODE_ENV === 'development') { + AlertComponent.displayName = 'Alert'; +} // ---------------------------------------------------------------------------- // Alert.Wrapper component @@ -101,7 +103,9 @@ const AlertWrapper = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'div', AlertOwnProps>; -AlertWrapper.displayName = 'Alert.Wrapper'; +if (process.env.NODE_ENV === 'development') { + AlertWrapper.displayName = 'Alert.Wrapper'; +} // ---------------------------------------------------------------------------- // Alert.Icon component @@ -119,13 +123,17 @@ const AlertIcon = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'span', React.ComponentProps>; -AlertIcon.displayName = 'Alert.Icon'; +if (process.env.NODE_ENV === 'development') { + AlertIcon.displayName = 'Alert.Icon'; +} // ---------------------------------------------------------------------------- // Alert.Message component const AlertMessage = polymorphic.span('iui-alert-message'); -AlertMessage.displayName = 'Alert.Message'; +if (process.env.NODE_ENV === 'development') { + AlertMessage.displayName = 'Alert.Message'; +} // ---------------------------------------------------------------------------- // Alert.Action component @@ -147,7 +155,9 @@ const AlertAction = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'a'>; -AlertAction.displayName = 'Alert.Action'; +if (process.env.NODE_ENV === 'development') { + AlertAction.displayName = 'Alert.Action'; +} // ---------------------------------------------------------------------------- // Alert.CloseButton component @@ -167,7 +177,9 @@ const AlertCloseButton = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'button'>; -AlertCloseButton.displayName = 'Alert.CloseButton'; +if (process.env.NODE_ENV === 'development') { + AlertCloseButton.displayName = 'Alert.CloseButton'; +} /** * A small box to quickly grab user attention and communicate a brief message diff --git a/packages/itwinui-react/src/core/Breadcrumbs/Breadcrumbs.tsx b/packages/itwinui-react/src/core/Breadcrumbs/Breadcrumbs.tsx index 9f16c08bd24..8d1dc8be6c1 100644 --- a/packages/itwinui-react/src/core/Breadcrumbs/Breadcrumbs.tsx +++ b/packages/itwinui-react/src/core/Breadcrumbs/Breadcrumbs.tsx @@ -257,7 +257,9 @@ const BreadcrumbsItem = React.forwardRef((props, forwardedRef) => { /> ); }) as PolymorphicForwardRefComponent<'a'>; -BreadcrumbsItem.displayName = 'Breadcrumbs.Item'; +if (process.env.NODE_ENV === 'development') { + BreadcrumbsItem.displayName = 'Breadcrumbs.Item'; +} // ---------------------------------------------------------------------------- diff --git a/packages/itwinui-react/src/core/ButtonGroup/ButtonGroup.tsx b/packages/itwinui-react/src/core/ButtonGroup/ButtonGroup.tsx index 9d6eee4a7df..6e4dc7488b8 100644 --- a/packages/itwinui-react/src/core/ButtonGroup/ButtonGroup.tsx +++ b/packages/itwinui-react/src/core/ButtonGroup/ButtonGroup.tsx @@ -21,7 +21,9 @@ import { export const ButtonGroupContext = React.createContext( undefined, ); -ButtonGroupContext.displayName = 'ButtonGroupContext'; +if (process.env.NODE_ENV === 'development') { + ButtonGroupContext.displayName = 'ButtonGroupContext'; +} // ---------------------------------------------------------------------------- diff --git a/packages/itwinui-react/src/core/ComboBox/ComboBoxEndIcon.tsx b/packages/itwinui-react/src/core/ComboBox/ComboBoxEndIcon.tsx index 3c2b66e8ff3..61ecce702a4 100644 --- a/packages/itwinui-react/src/core/ComboBox/ComboBoxEndIcon.tsx +++ b/packages/itwinui-react/src/core/ComboBox/ComboBoxEndIcon.tsx @@ -34,4 +34,6 @@ export const ComboBoxEndIcon = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'span', ComboBoxEndIconProps>; -ComboBoxEndIcon.displayName = 'ComboBoxEndIcon'; +if (process.env.NODE_ENV === 'development') { + ComboBoxEndIcon.displayName = 'ComboBoxEndIcon'; +} diff --git a/packages/itwinui-react/src/core/ComboBox/ComboBoxInput.tsx b/packages/itwinui-react/src/core/ComboBox/ComboBoxInput.tsx index f573b64c951..704e7642cc5 100644 --- a/packages/itwinui-react/src/core/ComboBox/ComboBoxInput.tsx +++ b/packages/itwinui-react/src/core/ComboBox/ComboBoxInput.tsx @@ -241,4 +241,6 @@ export const ComboBoxInput = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'input', ComboBoxInputProps>; -ComboBoxInput.displayName = 'ComboBoxInput'; +if (process.env.NODE_ENV === 'development') { + ComboBoxInput.displayName = 'ComboBoxInput'; +} diff --git a/packages/itwinui-react/src/core/ComboBox/ComboBoxInputContainer.tsx b/packages/itwinui-react/src/core/ComboBox/ComboBoxInputContainer.tsx index 82012b8e5d9..371874a6a36 100644 --- a/packages/itwinui-react/src/core/ComboBox/ComboBoxInputContainer.tsx +++ b/packages/itwinui-react/src/core/ComboBox/ComboBoxInputContainer.tsx @@ -47,4 +47,6 @@ export const ComboBoxInputContainer = React.forwardRef( ); }, ) as PolymorphicForwardRefComponent<'div', ComboBoxInputContainerProps>; -ComboBoxInputContainer.displayName = 'ComboBoxInputContainer'; +if (process.env.NODE_ENV === 'development') { + ComboBoxInputContainer.displayName = 'ComboBoxInputContainer'; +} diff --git a/packages/itwinui-react/src/core/ComboBox/ComboBoxMenu.tsx b/packages/itwinui-react/src/core/ComboBox/ComboBoxMenu.tsx index a17cb38e69a..f7f40a76281 100644 --- a/packages/itwinui-react/src/core/ComboBox/ComboBoxMenu.tsx +++ b/packages/itwinui-react/src/core/ComboBox/ComboBoxMenu.tsx @@ -156,4 +156,6 @@ export const ComboBoxMenu = React.forwardRef((props, forwardedRef) => { ) ); }) as PolymorphicForwardRefComponent<'div', ComboBoxMenuProps>; -ComboBoxMenu.displayName = 'ComboBoxMenu'; +if (process.env.NODE_ENV === 'development') { + ComboBoxMenu.displayName = 'ComboBoxMenu'; +} diff --git a/packages/itwinui-react/src/core/ComboBox/ComboBoxMenuItem.tsx b/packages/itwinui-react/src/core/ComboBox/ComboBoxMenuItem.tsx index 3cc09d372f5..89689d5bb56 100644 --- a/packages/itwinui-react/src/core/ComboBox/ComboBoxMenuItem.tsx +++ b/packages/itwinui-react/src/core/ComboBox/ComboBoxMenuItem.tsx @@ -79,4 +79,6 @@ export const ComboBoxMenuItem = React.memo( ); }) as PolymorphicForwardRefComponent<'div', ComboBoxMenuItemProps>, ); -ComboBoxMenuItem.displayName = 'ComboBoxMenuItem'; +if (process.env.NODE_ENV === 'development') { + ComboBoxMenuItem.displayName = 'ComboBoxMenuItem'; +} diff --git a/packages/itwinui-react/src/core/ComboBox/ComboBoxMultipleContainer.tsx b/packages/itwinui-react/src/core/ComboBox/ComboBoxMultipleContainer.tsx index 98724315473..27d01017576 100644 --- a/packages/itwinui-react/src/core/ComboBox/ComboBoxMultipleContainer.tsx +++ b/packages/itwinui-react/src/core/ComboBox/ComboBoxMultipleContainer.tsx @@ -15,4 +15,6 @@ export const ComboBoxMultipleContainer = React.forwardRef((props, ref) => { return ; }) as PolymorphicForwardRefComponent<'div', ComboBoxMultipleContainerProps>; -ComboBoxMultipleContainer.displayName = 'ComboBoxMultipleContainer'; +if (process.env.NODE_ENV === 'development') { + ComboBoxMultipleContainer.displayName = 'ComboBoxMultipleContainer'; +} diff --git a/packages/itwinui-react/src/core/ComboBox/helpers.ts b/packages/itwinui-react/src/core/ComboBox/helpers.ts index 8343a5b1a74..27437f13c1e 100644 --- a/packages/itwinui-react/src/core/ComboBox/helpers.ts +++ b/packages/itwinui-react/src/core/ComboBox/helpers.ts @@ -14,7 +14,9 @@ export const ComboBoxRefsContext = React.createContext< } | undefined >(undefined); -ComboBoxRefsContext.displayName = 'ComboBoxRefsContext'; +if (process.env.NODE_ENV === 'development') { + ComboBoxRefsContext.displayName = 'ComboBoxRefsContext'; +} type ComboBoxStateContextProps = { isOpen: boolean; @@ -34,4 +36,6 @@ type ComboBoxStateContextProps = { export const ComboBoxStateContext = React.createContext< ComboBoxStateContextProps | undefined >(undefined); -ComboBoxStateContext.displayName = 'ComboBoxStateContext'; +if (process.env.NODE_ENV === 'development') { + ComboBoxStateContext.displayName = 'ComboBoxStateContext'; +} diff --git a/packages/itwinui-react/src/core/ExpandableBlock/ExpandableBlock.tsx b/packages/itwinui-react/src/core/ExpandableBlock/ExpandableBlock.tsx index 5c02385e64c..da7331ac078 100644 --- a/packages/itwinui-react/src/core/ExpandableBlock/ExpandableBlock.tsx +++ b/packages/itwinui-react/src/core/ExpandableBlock/ExpandableBlock.tsx @@ -28,7 +28,9 @@ const ExpandableBlockContext = React.createContext< } & ExpandableBlockOwnProps) | undefined >(undefined); -ExpandableBlockContext.displayName = 'ExpandableBlockContext'; +if (process.env.NODE_ENV === 'development') { + ExpandableBlockContext.displayName = 'ExpandableBlockContext'; +} // ---------------------------------------------------------------------------- // Main ExpandableBlock component @@ -90,7 +92,9 @@ const ExpandableBlockComponent = React.forwardRef((props, forwardedRef) => { 'div', ExpandableBlockOwnProps & ExpandableBlockLegacyProps >; -ExpandableBlockComponent.displayName = 'ExpandableBlock'; +if (process.env.NODE_ENV === 'development') { + ExpandableBlockComponent.displayName = 'ExpandableBlock'; +} // ---------------------------------------------------------------------------- @@ -144,7 +148,9 @@ const ExpandableBlockWrapper = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', ExpandableBlockOwnProps>; -ExpandableBlockWrapper.displayName = 'ExpandableBlock.Wrapper'; +if (process.env.NODE_ENV === 'development') { + ExpandableBlockWrapper.displayName = 'ExpandableBlock.Wrapper'; +} // ---------------------------------------------------------------------------- // ExpandableBlock.Trigger component @@ -184,7 +190,9 @@ const ExpandableBlockTrigger = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', ExpandableBlockTriggerOwnProps>; -ExpandableBlockTrigger.displayName = 'ExpandableBlock.Trigger'; +if (process.env.NODE_ENV === 'development') { + ExpandableBlockTrigger.displayName = 'ExpandableBlock.Trigger'; +} // ---------------------------------------------------------------------------- // ExpandableBlock.ExpandIcon component @@ -201,13 +209,17 @@ const ExpandableBlockExpandIcon = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'span'>; -ExpandableBlockExpandIcon.displayName = 'ExpandableBlock.ExpandIcon'; +if (process.env.NODE_ENV === 'development') { + ExpandableBlockExpandIcon.displayName = 'ExpandableBlock.ExpandIcon'; +} // ---------------------------------------------------------------------------- // ExpandableBlock.LabelArea component const ExpandableBlockLabelArea = polymorphic.span('iui-expandable-block-label'); -ExpandableBlockLabelArea.displayName = 'ExpandableBlock.LabelArea'; +if (process.env.NODE_ENV === 'development') { + ExpandableBlockLabelArea.displayName = 'ExpandableBlock.LabelArea'; +} // ---------------------------------------------------------------------------- // ExpandableBlock.Title component @@ -238,7 +250,9 @@ const ExpandableBlockTitle = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'button'>; -ExpandableBlockTitle.displayName = 'ExpandableBlock.Title'; +if (process.env.NODE_ENV === 'development') { + ExpandableBlockTitle.displayName = 'ExpandableBlock.Title'; +} // ---------------------------------------------------------------------------- // ExpandableBlock.Caption component @@ -262,7 +276,9 @@ const ExpandableBlockCaption = React.forwardRef((props, forwardedRef) => { /> ); }) as PolymorphicForwardRefComponent<'div'>; -ExpandableBlockCaption.displayName = 'ExpandableBlock.Caption'; +if (process.env.NODE_ENV === 'development') { + ExpandableBlockCaption.displayName = 'ExpandableBlock.Caption'; +} // ---------------------------------------------------------------------------- // ExpandableBlock.EndIcon component @@ -281,7 +297,9 @@ const ExpandableBlockEndIcon = React.forwardRef((props, forwardedRef) => { 'span', React.ComponentPropsWithoutRef >; -ExpandableBlockEndIcon.displayName = 'ExpandableBlock.EndIcon'; +if (process.env.NODE_ENV === 'development') { + ExpandableBlockEndIcon.displayName = 'ExpandableBlock.EndIcon'; +} // ---------------------------------------------------------------------------- // ExpandableBlock.Content component @@ -302,7 +320,9 @@ const ExpandableBlockContent = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', ExpandableBlockContentOwnProps>; -ExpandableBlockContent.displayName = 'ExpandableBlock.Content'; +if (process.env.NODE_ENV === 'development') { + ExpandableBlockContent.displayName = 'ExpandableBlock.Content'; +} /** * Expandable block with customizable Title, Caption, Content and EndIcon subcomponents. diff --git a/packages/itwinui-react/src/core/FileUpload/FileUploadCard.tsx b/packages/itwinui-react/src/core/FileUpload/FileUploadCard.tsx index 754fb2cba6a..52e1c9d46e4 100644 --- a/packages/itwinui-react/src/core/FileUpload/FileUploadCard.tsx +++ b/packages/itwinui-react/src/core/FileUpload/FileUploadCard.tsx @@ -41,13 +41,17 @@ const toDate = (dateNumber: number) => { const FileUploadCardIcon = polymorphic.span('iui-file-card-icon', { children: , }); -FileUploadCardIcon.displayName = 'FileUploadCard.Icon'; +if (process.env.NODE_ENV === 'development') { + FileUploadCardIcon.displayName = 'FileUploadCard.Icon'; +} // ---------------------------------------------------------------------------- // FileUploadCard.Info component const FileUploadCardInfo = polymorphic.span('iui-file-card-text'); -FileUploadCardInfo.displayName = 'FileUploadCard.Info'; +if (process.env.NODE_ENV === 'development') { + FileUploadCardInfo.displayName = 'FileUploadCard.Info'; +} // ---------------------------------------------------------------------------- // FileUploadCard.Title component @@ -68,7 +72,9 @@ const FileUploadCardTitle = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'span'>; -FileUploadCardTitle.displayName = 'FileUploadCard.Title'; +if (process.env.NODE_ENV === 'development') { + FileUploadCardTitle.displayName = 'FileUploadCard.Title'; +} // ---------------------------------------------------------------------------- // FileUploadCard.Description component @@ -97,13 +103,17 @@ const FileUploadCardDescription = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'span'>; -FileUploadCardDescription.displayName = 'FileUploadCard.Description'; +if (process.env.NODE_ENV === 'development') { + FileUploadCardDescription.displayName = 'FileUploadCard.Description'; +} // ---------------------------------------------------------------------------- // FileUploadCard.Action component const FileUploadCardAction = polymorphic.div('iui-file-card-action'); -FileUploadCardAction.displayName = 'FileUploadCard.Action'; +if (process.env.NODE_ENV === 'development') { + FileUploadCardAction.displayName = 'FileUploadCard.Action'; +} // ---------------------------------------------------------------------------- // FileUploadCard.InputLabel component @@ -117,7 +127,9 @@ const FileUploadCardInputLabel = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'label'>; -FileUploadCardInputLabel.displayName = 'FileUploadCard.InputLabel'; +if (process.env.NODE_ENV === 'development') { + FileUploadCardInputLabel.displayName = 'FileUploadCard.InputLabel'; +} // ---------------------------------------------------------------------------- // FileUploadCard.Input component @@ -168,7 +180,9 @@ const FileUploadCardInput = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'input'>; -FileUploadCardInput.displayName = 'FileUploadCard.Input'; +if (process.env.NODE_ENV === 'development') { + FileUploadCardInput.displayName = 'FileUploadCard.Input'; +} // ---------------------------------------------------------------------------- // FileUploadCard component @@ -277,7 +291,9 @@ export const FileUploadCard = Object.assign(FileUploadCardComponent, { InputLabel: FileUploadCardInputLabel, Input: FileUploadCardInput, }); -FileUploadCard.displayName = 'FileUploadCard'; +if (process.env.NODE_ENV === 'development') { + FileUploadCard.displayName = 'FileUploadCard'; +} export const FileUploadCardContext = React.createContext< | { diff --git a/packages/itwinui-react/src/core/Flex/Flex.tsx b/packages/itwinui-react/src/core/Flex/Flex.tsx index 95e76b07f79..03811000ff7 100644 --- a/packages/itwinui-react/src/core/Flex/Flex.tsx +++ b/packages/itwinui-react/src/core/Flex/Flex.tsx @@ -67,7 +67,9 @@ const FlexComponent = React.forwardRef((props, ref) => { /> ); }) as PolymorphicForwardRefComponent<'div', FlexOwnProps>; -FlexComponent.displayName = 'Flex'; +if (process.env.NODE_ENV === 'development') { + FlexComponent.displayName = 'Flex'; +} type FlexOwnProps = { /** @@ -125,7 +127,9 @@ const FlexSpacer = React.forwardRef((props, ref) => { /> ); }) as PolymorphicForwardRefComponent<'div', FlexSpacerOwnProps>; -FlexSpacer.displayName = 'Flex.Spacer'; +if (process.env.NODE_ENV === 'development') { + FlexSpacer.displayName = 'Flex.Spacer'; +} type FlexSpacerOwnProps = { /** @@ -169,7 +173,9 @@ const FlexItem = React.forwardRef((props, ref) => { /> ); }) as PolymorphicForwardRefComponent<'div', FlexItemOwnProps>; -FlexItem.displayName = 'Flex.Item'; +if (process.env.NODE_ENV === 'development') { + FlexItem.displayName = 'Flex.Item'; +} type FlexItemOwnProps = { /** diff --git a/packages/itwinui-react/src/core/InputWithDecorations/InputWithDecorations.tsx b/packages/itwinui-react/src/core/InputWithDecorations/InputWithDecorations.tsx index 4cc8703e224..6a7f5bcd49b 100644 --- a/packages/itwinui-react/src/core/InputWithDecorations/InputWithDecorations.tsx +++ b/packages/itwinui-react/src/core/InputWithDecorations/InputWithDecorations.tsx @@ -55,7 +55,9 @@ const InputWithDecorationsInput = React.forwardRef((props, ref) => { /> ); }) as PolymorphicForwardRefComponent<'input', InputProps>; -InputWithDecorationsInput.displayName = 'InputWithDecorations.Input'; +if (process.env.NODE_ENV === 'development') { + InputWithDecorationsInput.displayName = 'InputWithDecorations.Input'; +} // ---------------------------------------------------------------------------- @@ -79,12 +81,16 @@ const InputWithDecorationsButton = React.forwardRef((props, ref) => { 'button', React.ComponentProps >; -InputWithDecorationsButton.displayName = 'InputWithDecorations.Button'; +if (process.env.NODE_ENV === 'development') { + InputWithDecorationsButton.displayName = 'InputWithDecorations.Button'; +} // ---------------------------------------------------------------------------- const InputWithDecorationsIcon = InputFlexContainerIcon; -InputWithDecorationsIcon.displayName = 'InputWithDecorations.Icon'; +if (process.env.NODE_ENV === 'development') { + InputWithDecorationsIcon.displayName = 'InputWithDecorations.Icon'; +} // ---------------------------------------------------------------------------- diff --git a/packages/itwinui-react/src/core/LinkAction/LinkAction.tsx b/packages/itwinui-react/src/core/LinkAction/LinkAction.tsx index 50c143e6e29..fb1eb5a3226 100644 --- a/packages/itwinui-react/src/core/LinkAction/LinkAction.tsx +++ b/packages/itwinui-react/src/core/LinkAction/LinkAction.tsx @@ -29,7 +29,9 @@ export const LinkAction = React.forwardRef((props, forwardedRef) => { /> ); }) as PolymorphicForwardRefComponent<'a'>; -LinkAction.displayName = 'LinkAction'; +if (process.env.NODE_ENV === 'development') { + LinkAction.displayName = 'LinkAction'; +} /** * Polymorphic link box component. @@ -43,4 +45,6 @@ LinkAction.displayName = 'LinkAction'; * */ export const LinkBox = polymorphic.div('iui-link-box'); -LinkBox.displayName = 'LinkBox'; +if (process.env.NODE_ENV === 'development') { + LinkBox.displayName = 'LinkBox'; +} diff --git a/packages/itwinui-react/src/core/List/List.tsx b/packages/itwinui-react/src/core/List/List.tsx index 629078c6323..e872cdd082e 100644 --- a/packages/itwinui-react/src/core/List/List.tsx +++ b/packages/itwinui-react/src/core/List/List.tsx @@ -5,4 +5,6 @@ import { polymorphic } from '../../utils/index.js'; export const List = polymorphic.ul('iui-list', { role: 'list' }); -List.displayName = 'List'; +if (process.env.NODE_ENV === 'development') { + List.displayName = 'List'; +} diff --git a/packages/itwinui-react/src/core/List/ListItem.tsx b/packages/itwinui-react/src/core/List/ListItem.tsx index 8e85d041ec4..2613baea238 100644 --- a/packages/itwinui-react/src/core/List/ListItem.tsx +++ b/packages/itwinui-react/src/core/List/ListItem.tsx @@ -33,7 +33,9 @@ const ListItemComponent = React.forwardRef((props, ref) => { /> ); }) as PolymorphicForwardRefComponent<'li', ListItemOwnProps>; -ListItemComponent.displayName = 'ListItem'; +if (process.env.NODE_ENV === 'development') { + ListItemComponent.displayName = 'ListItem'; +} export type ListItemOwnProps = { /** @@ -67,22 +69,30 @@ export type ListItemOwnProps = { // ---------------------------------------------------------------------------- const ListItemIcon = polymorphic('iui-list-item-icon'); -ListItemIcon.displayName = 'ListItem.Icon'; +if (process.env.NODE_ENV === 'development') { + ListItemIcon.displayName = 'ListItem.Icon'; +} // ---------------------------------------------------------------------------- const ListItemContent = polymorphic('iui-list-item-content'); -ListItemContent.displayName = 'ListItem.Content'; +if (process.env.NODE_ENV === 'development') { + ListItemContent.displayName = 'ListItem.Content'; +} // ---------------------------------------------------------------------------- const ListItemDescription = polymorphic('iui-list-item-description'); -ListItemDescription.displayName = 'ListItem.Description'; +if (process.env.NODE_ENV === 'development') { + ListItemDescription.displayName = 'ListItem.Description'; +} // ---------------------------------------------------------------------------- const ListItemAction = LinkAction; -ListItemAction.displayName = 'ListItem.Action'; +if (process.env.NODE_ENV === 'development') { + ListItemAction.displayName = 'ListItem.Action'; +} // ---------------------------------------------------------------------------- // Exported compound component diff --git a/packages/itwinui-react/src/core/Overlay/Overlay.tsx b/packages/itwinui-react/src/core/Overlay/Overlay.tsx index 76cad96e2e1..c8934a6861a 100644 --- a/packages/itwinui-react/src/core/Overlay/Overlay.tsx +++ b/packages/itwinui-react/src/core/Overlay/Overlay.tsx @@ -31,7 +31,9 @@ const OverlayComponent = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', OverlayComponentProps>; -OverlayComponent.displayName = 'Overlay'; +if (process.env.NODE_ENV === 'development') { + OverlayComponent.displayName = 'Overlay'; +} // -------------------------------------------------------------------------------- @@ -44,17 +46,23 @@ const OverlayHiddenContent = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'div'>; -OverlayHiddenContent.displayName = 'Overlay.HiddenContent'; +if (process.env.NODE_ENV === 'development') { + OverlayHiddenContent.displayName = 'Overlay.HiddenContent'; +} // -------------------------------------------------------------------------------- const OverlayOverlay = polymorphic('iui-overlay'); -OverlayOverlay.displayName = 'Overlay.Overlay'; +if (process.env.NODE_ENV === 'development') { + OverlayOverlay.displayName = 'Overlay.Overlay'; +} // -------------------------------------------------------------------------------- const OverlayWrapper = polymorphic('iui-overlay-wrapper'); -OverlayWrapper.displayName = 'Overlay.Wrapper'; +if (process.env.NODE_ENV === 'development') { + OverlayWrapper.displayName = 'Overlay.Wrapper'; +} // -------------------------------------------------------------------------------- diff --git a/packages/itwinui-react/src/core/SearchBox/SearchBox.tsx b/packages/itwinui-react/src/core/SearchBox/SearchBox.tsx index 0daab693b84..a31dd33f60c 100644 --- a/packages/itwinui-react/src/core/SearchBox/SearchBox.tsx +++ b/packages/itwinui-react/src/core/SearchBox/SearchBox.tsx @@ -198,7 +198,9 @@ const SearchBoxCollapsedState = ({ return <>{children ?? }; }; -SearchBoxCollapsedState.displayName = 'SearchBox.CollapsedState'; +if (process.env.NODE_ENV === 'development') { + SearchBoxCollapsedState.displayName = 'SearchBox.CollapsedState'; +} // ---------------------------------------------------------------------------- @@ -215,7 +217,9 @@ const SearchBoxExpandedState = ({ return <>{children}; }; -SearchBoxExpandedState.displayName = 'SearchBox.ExpandedState'; +if (process.env.NODE_ENV === 'development') { + SearchBoxExpandedState.displayName = 'SearchBox.ExpandedState'; +} // ---------------------------------------------------------------------------- @@ -233,7 +237,9 @@ const SearchBoxIcon = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'span', IconProps>; -SearchBoxIcon.displayName = 'SearchBox.Icon'; +if (process.env.NODE_ENV === 'development') { + SearchBoxIcon.displayName = 'SearchBox.Icon'; +} // ---------------------------------------------------------------------------- @@ -262,7 +268,9 @@ const SearchBoxInput = React.forwardRef((props, ref) => { /> ); }) as PolymorphicForwardRefComponent<'input'>; -SearchBoxInput.displayName = 'SearchBox.Input'; +if (process.env.NODE_ENV === 'development') { + SearchBoxInput.displayName = 'SearchBox.Input'; +} // ---------------------------------------------------------------------------- @@ -281,7 +289,9 @@ const SearchBoxButton = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'button', IconButtonProps>; -SearchBoxButton.displayName = 'SearchBox.Button'; +if (process.env.NODE_ENV === 'development') { + SearchBoxButton.displayName = 'SearchBox.Button'; +} // ---------------------------------------------------------------------------- @@ -307,7 +317,9 @@ const SearchBoxCollapseButton = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'button', IconButtonProps>; -SearchBoxCollapseButton.displayName = 'SearchBox.CollapseButton'; +if (process.env.NODE_ENV === 'development') { + SearchBoxCollapseButton.displayName = 'SearchBox.CollapseButton'; +} // ---------------------------------------------------------------------------- @@ -335,7 +347,9 @@ const SearchBoxExpandButton = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'button', IconButtonProps>; -SearchBoxExpandButton.displayName = 'SearchBox.ExpandButton'; +if (process.env.NODE_ENV === 'development') { + SearchBoxExpandButton.displayName = 'SearchBox.ExpandButton'; +} // ---------------------------------------------------------------------------- @@ -390,4 +404,6 @@ export const SearchBox = Object.assign(SearchBoxComponent, { CollapsedState: SearchBoxCollapsedState, }); -SearchBox.displayName = 'SearchBox'; +if (process.env.NODE_ENV === 'development') { + SearchBox.displayName = 'SearchBox'; +} diff --git a/packages/itwinui-react/src/core/Tabs/Tabs.tsx b/packages/itwinui-react/src/core/Tabs/Tabs.tsx index 23de277d1d9..45d5a737080 100644 --- a/packages/itwinui-react/src/core/Tabs/Tabs.tsx +++ b/packages/itwinui-react/src/core/Tabs/Tabs.tsx @@ -130,7 +130,9 @@ const TabsWrapper = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'div', TabsWrapperOwnProps>; -TabsWrapper.displayName = 'Tabs.Wrapper'; +if (process.env.NODE_ENV === 'development') { + TabsWrapper.displayName = 'Tabs.Wrapper'; +} // ---------------------------------------------------------------------------- // Tabs.TabList component @@ -185,7 +187,9 @@ const TabList = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'div', TabListOwnProps>; -TabList.displayName = 'Tabs.TabList'; +if (process.env.NODE_ENV === 'development') { + TabList.displayName = 'Tabs.TabList'; +} // ---------------------------------------------------------------------------- // Tabs.Tab component @@ -367,7 +371,9 @@ const Tab = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'button', TabOwnProps>; -Tab.displayName = 'Tabs.Tab'; +if (process.env.NODE_ENV === 'development') { + Tab.displayName = 'Tabs.Tab'; +} // ---------------------------------------------------------------------------- // Tabs.TabIcon component @@ -381,13 +387,17 @@ const TabIcon = React.forwardRef((props, ref) => { /> ); }) as PolymorphicForwardRefComponent<'span', React.ComponentProps>; -TabIcon.displayName = 'Tabs.TabIcon'; +if (process.env.NODE_ENV === 'development') { + TabIcon.displayName = 'Tabs.TabIcon'; +} // ---------------------------------------------------------------------------- // Tabs.TabLabel component const TabLabel = polymorphic.span('iui-tab-label'); -TabLabel.displayName = 'Tabs.TabLabel'; +if (process.env.NODE_ENV === 'development') { + TabLabel.displayName = 'Tabs.TabLabel'; +} // ---------------------------------------------------------------------------- // Tabs.TabDescription component @@ -413,7 +423,9 @@ const TabDescription = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'span'>; -TabDescription.displayName = 'Tabs.TabDescription'; +if (process.env.NODE_ENV === 'development') { + TabDescription.displayName = 'Tabs.TabDescription'; +} // ---------------------------------------------------------------------------- // Tabs.Actions component @@ -439,7 +451,9 @@ const TabsActions = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'div', TabsActionsOwnProps>; -TabsActions.displayName = 'Tabs.Actions'; +if (process.env.NODE_ENV === 'development') { + TabsActions.displayName = 'Tabs.Actions'; +} // ---------------------------------------------------------------------------- // Tabs.Panel component @@ -474,7 +488,9 @@ const TabsPanel = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'div', TabsPanelOwnProps>; -TabsPanel.displayName = 'Tabs.Panel'; +if (process.env.NODE_ENV === 'development') { + TabsPanel.displayName = 'Tabs.Panel'; +} // ---------------------------------------------------------------------------- // Tabs legacy component @@ -600,7 +616,9 @@ const LegacyTabsComponent = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', TabsLegacyProps>; -LegacyTabsComponent.displayName = 'Tabs'; +if (process.env.NODE_ENV === 'development') { + LegacyTabsComponent.displayName = 'Tabs'; +} // ---------------------------------------------------------------------------- diff --git a/packages/itwinui-react/src/core/ThemeProvider/ThemeProvider.tsx b/packages/itwinui-react/src/core/ThemeProvider/ThemeProvider.tsx index 8913c2cf1ab..4bcac443fce 100644 --- a/packages/itwinui-react/src/core/ThemeProvider/ThemeProvider.tsx +++ b/packages/itwinui-react/src/core/ThemeProvider/ThemeProvider.tsx @@ -205,7 +205,9 @@ export const ThemeProvider = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', ThemeProviderOwnProps>; -ThemeProvider.displayName = 'ThemeProvider'; +if (process.env.NODE_ENV === 'development') { + ThemeProvider.displayName = 'ThemeProvider'; +} // ---------------------------------------------------------------------------- diff --git a/packages/itwinui-react/src/core/Tile/Tile.tsx b/packages/itwinui-react/src/core/Tile/Tile.tsx index d1142768ce4..fefac749d51 100644 --- a/packages/itwinui-react/src/core/Tile/Tile.tsx +++ b/packages/itwinui-react/src/core/Tile/Tile.tsx @@ -61,7 +61,9 @@ const TileContext = React.createContext< } | undefined >(undefined); -TileContext.displayName = 'TileContext'; +if (process.env.NODE_ENV === 'development') { + TileContext.displayName = 'TileContext'; +} // ---------------------------------------------------------------------------- // Main Tile component @@ -148,7 +150,9 @@ const TileWrapper = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', TileWrapperOwnProps>; -TileWrapper.displayName = 'Tile.Wrapper'; +if (process.env.NODE_ENV === 'development') { + TileWrapper.displayName = 'Tile.Wrapper'; +} // ---------------------------------------------------------------------------- // Tile.Action component @@ -175,13 +179,17 @@ const TileAction = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'a'>; -TileAction.displayName = 'Tile.Action'; +if (process.env.NODE_ENV === 'development') { + TileAction.displayName = 'Tile.Action'; +} // ---------------------------------------------------------------------------- // Tile.ThumbnailArea component const TileThumbnailArea = polymorphic('iui-tile-thumbnail'); -TileThumbnailArea.displayName = 'Tile.ThumbnailArea'; +if (process.env.NODE_ENV === 'development') { + TileThumbnailArea.displayName = 'Tile.ThumbnailArea'; +} // ---------------------------------------------------------------------------- // Tile.ThumbnailPicture component @@ -219,19 +227,25 @@ const TileThumbnailPicture = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', TileThumbnailPictureOwnProps>; -TileThumbnailPicture.displayName = 'Tile.TileThumbnailPicture'; +if (process.env.NODE_ENV === 'development') { + TileThumbnailPicture.displayName = 'Tile.TileThumbnailPicture'; +} // ---------------------------------------------------------------------------- // Tile.QuickAction component const TileQuickAction = polymorphic('iui-tile-thumbnail-quick-action'); -TileQuickAction.displayName = 'Tile.QuickAction'; +if (process.env.NODE_ENV === 'development') { + TileQuickAction.displayName = 'Tile.QuickAction'; +} // ---------------------------------------------------------------------------- // Tile.TypeIndicator component const TileTypeIndicator = polymorphic('iui-tile-thumbnail-type-indicator'); -TileTypeIndicator.displayName = 'Tile.TypeIndicator'; +if (process.env.NODE_ENV === 'development') { + TileTypeIndicator.displayName = 'Tile.TypeIndicator'; +} // ---------------------------------------------------------------------------- // Tile.IconButton component @@ -253,13 +267,17 @@ const TileIconButton = React.forwardRef((props, forwardedRef) => { 'button', React.ComponentPropsWithoutRef >; -TileIconButton.displayName = 'Tile.IconButton'; +if (process.env.NODE_ENV === 'development') { + TileIconButton.displayName = 'Tile.IconButton'; +} // ---------------------------------------------------------------------------- // Tile.BadgeContainer component const TileBadgeContainer = polymorphic('iui-tile-thumbnail-badge-container'); -TileBadgeContainer.displayName = 'Tile.BadgeContainer'; +if (process.env.NODE_ENV === 'development') { + TileBadgeContainer.displayName = 'Tile.BadgeContainer'; +} // ---------------------------------------------------------------------------- // Tile.Name component @@ -279,7 +297,9 @@ const TileName = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', TileNameOwnProps>; -TileBadgeContainer.displayName = 'Tile.Name'; +if (process.env.NODE_ENV === 'development') { + TileBadgeContainer.displayName = 'Tile.Name'; +} // ---------------------------------------------------------------------------- // Tile.NameIcon component @@ -314,31 +334,41 @@ const TileNameIcon = React.forwardRef((props, forwardedRef) => { ) : null; }) as PolymorphicForwardRefComponent<'div'>; -TileNameIcon.displayName = 'Tile.NameIcon'; +if (process.env.NODE_ENV === 'development') { + TileNameIcon.displayName = 'Tile.NameIcon'; +} // ---------------------------------------------------------------------------- // Tile.NameLabel component const TileNameLabel = polymorphic.span('iui-tile-name-label'); -TileNameLabel.displayName = 'Tile.NameLabel'; +if (process.env.NODE_ENV === 'development') { + TileNameLabel.displayName = 'Tile.NameLabel'; +} // ---------------------------------------------------------------------------- // Tile.ContentArea component const TileContentArea = polymorphic('iui-tile-content'); -TileContentArea.displayName = 'Tile.ContentArea'; +if (process.env.NODE_ENV === 'development') { + TileContentArea.displayName = 'Tile.ContentArea'; +} // ---------------------------------------------------------------------------- // Tile.Description component const TileDescription = polymorphic('iui-tile-description'); -TileDescription.displayName = 'Tile.Description'; +if (process.env.NODE_ENV === 'development') { + TileDescription.displayName = 'Tile.Description'; +} // ---------------------------------------------------------------------------- // Tile.Metadata component const TileMetadata = polymorphic('iui-tile-metadata'); -TileMetadata.displayName = 'Tile.Metadata'; +if (process.env.NODE_ENV === 'development') { + TileMetadata.displayName = 'Tile.Metadata'; +} // ---------------------------------------------------------------------------- // Tile.MoreOptions component @@ -388,13 +418,17 @@ const TileMoreOptions = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', TileMoreOptionsOwnProps>; -TileMoreOptions.displayName = 'Tile.MoreOptions'; +if (process.env.NODE_ENV === 'development') { + TileMoreOptions.displayName = 'Tile.MoreOptions'; +} // ---------------------------------------------------------------------------- // Tile.Buttons component const TileButtons = polymorphic('iui-tile-buttons'); -TileButtons.displayName = 'Tile.Buttons'; +if (process.env.NODE_ENV === 'development') { + TileButtons.displayName = 'Tile.Buttons'; +} // ---------------------------------------------------------------------------- type TileLegacyProps = { @@ -576,7 +610,9 @@ const TileComponent = React.forwardRef((props, forwardedRef) => { ); }) as PolymorphicForwardRefComponent<'div', TileLegacyProps>; -TileComponent.displayName = 'Tile'; +if (process.env.NODE_ENV === 'development') { + TileComponent.displayName = 'Tile'; +} /** * Tile with customizable Thumbnail, Name, Content and Buttons subcomponents diff --git a/packages/itwinui-react/src/core/Toast/Toaster.tsx b/packages/itwinui-react/src/core/Toast/Toaster.tsx index 383bcbeaac9..bdc6b2f13c4 100644 --- a/packages/itwinui-react/src/core/Toast/Toaster.tsx +++ b/packages/itwinui-react/src/core/Toast/Toaster.tsx @@ -152,7 +152,9 @@ const toastReducer = (state: ToasterState, action: ToasterAction) => { export const ToasterStateContext = React.createContext< ToasterState | undefined >(undefined); -ToasterStateContext.displayName = 'ToasterStateContext'; +if (process.env.NODE_ENV === 'development') { + ToasterStateContext.displayName = 'ToasterStateContext'; +} type ToasterState = { toasts: ToastProps[]; settings: ToasterSettings }; @@ -161,7 +163,9 @@ type ToasterState = { toasts: ToastProps[]; settings: ToasterSettings }; const ToasterDispatchContext = React.createContext< React.Dispatch | undefined >(undefined); -ToasterDispatchContext.displayName = 'ToasterDispatchContext'; +if (process.env.NODE_ENV === 'development') { + ToasterDispatchContext.displayName = 'ToasterDispatchContext'; +} type ToasterAction = | { type: 'add'; toast: ToastProps } diff --git a/packages/itwinui-react/src/core/TransferList/TransferList.tsx b/packages/itwinui-react/src/core/TransferList/TransferList.tsx index 67e70d52373..b6eb90e80f6 100644 --- a/packages/itwinui-react/src/core/TransferList/TransferList.tsx +++ b/packages/itwinui-react/src/core/TransferList/TransferList.tsx @@ -21,7 +21,9 @@ import { Label } from '../Label/Label.js'; // TransferListComponent const TransferListComponent = polymorphic('iui-transfer-list-wrapper'); -TransferListComponent.displayName = 'TransferList'; +if (process.env.NODE_ENV === 'development') { + TransferListComponent.displayName = 'TransferList'; +} // ---------------------------------------------------------------------------- // TransferList.ListboxWrapper component @@ -47,7 +49,9 @@ const TransferListListboxWrapper = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'div', TransferListListboxWrapperOwnProps>; -TransferListListboxWrapper.displayName = 'TransferList.ListboxWrapper'; +if (process.env.NODE_ENV === 'development') { + TransferListListboxWrapper.displayName = 'TransferList.ListboxWrapper'; +} // ---------------------------------------------------------------------------- // TransferList.Listbox component @@ -124,7 +128,9 @@ const TransferListListbox = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'ul', TransferListListboxOwnProps>; -TransferListListbox.displayName = 'TransferList.Listbox'; +if (process.env.NODE_ENV === 'development') { + TransferListListbox.displayName = 'TransferList.Listbox'; +} // ---------------------------------------------------------------------------- // TransferList.Item component @@ -182,7 +188,9 @@ const TransferListItem = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'li', TransferListItemOwnProps>; -TransferListItem.displayName = 'TransferList.Item'; +if (process.env.NODE_ENV === 'development') { + TransferListItem.displayName = 'TransferList.Item'; +} // ---------------------------------------------------------------------------- // TransferList.ListboxLabel component @@ -211,7 +219,9 @@ const TransferListListboxLabel = React.forwardRef((props, ref) => { ); }) as PolymorphicForwardRefComponent<'div', TransferListListboxLabelOwnProps>; -TransferListListboxLabel.displayName = 'TransferList.ListboxLabel'; +if (process.env.NODE_ENV === 'development') { + TransferListListboxLabel.displayName = 'TransferList.ListboxLabel'; +} // ---------------------------------------------------------------------------- // TransferList.Toolbar component @@ -219,7 +229,9 @@ TransferListListboxLabel.displayName = 'TransferList.ListboxLabel'; const TransferListToolbar = polymorphic('iui-transfer-list-toolbar', { role: 'toolbar', }); -TransferListToolbar.displayName = 'TransferList.Toolbar'; +if (process.env.NODE_ENV === 'development') { + TransferListToolbar.displayName = 'TransferList.Toolbar'; +} /** * The TransferList component is used to display a list within a box diff --git a/packages/itwinui-react/src/utils/components/ButtonBase.tsx b/packages/itwinui-react/src/utils/components/ButtonBase.tsx index 13e073d4176..82a8e29f7bc 100644 --- a/packages/itwinui-react/src/utils/components/ButtonBase.tsx +++ b/packages/itwinui-react/src/utils/components/ButtonBase.tsx @@ -49,7 +49,9 @@ export const ButtonBase = React.forwardRef((props, forwardedRef) => { /> ); }) as PolymorphicForwardRefComponent<'button', ButtonBaseProps>; -ButtonBase.displayName = 'ButtonBase'; +if (process.env.NODE_ENV === 'development') { + ButtonBase.displayName = 'ButtonBase'; +} type ButtonBaseProps = { /** diff --git a/packages/itwinui-react/src/utils/components/InputWithIcon.tsx b/packages/itwinui-react/src/utils/components/InputWithIcon.tsx index 496060a2df6..3b9ab8056aa 100644 --- a/packages/itwinui-react/src/utils/components/InputWithIcon.tsx +++ b/packages/itwinui-react/src/utils/components/InputWithIcon.tsx @@ -6,4 +6,6 @@ import { polymorphic } from '../functions/polymorphic.js'; /** @private */ export const InputWithIcon = polymorphic.div('iui-input-with-icon'); -InputWithIcon.displayName = 'InputWithIcon'; +if (process.env.NODE_ENV === 'development') { + InputWithIcon.displayName = 'InputWithIcon'; +} diff --git a/packages/itwinui-react/src/utils/functions/polymorphic.tsx b/packages/itwinui-react/src/utils/functions/polymorphic.tsx index f54c2d39e40..1c78436abfa 100644 --- a/packages/itwinui-react/src/utils/functions/polymorphic.tsx +++ b/packages/itwinui-react/src/utils/functions/polymorphic.tsx @@ -38,7 +38,9 @@ const _base = ( return ; }) as PolymorphicForwardRefComponent>; - Comp.displayName = getDisplayNameFromClass(className); + if (process.env.NODE_ENV === 'development') { + Comp.displayName = getDisplayNameFromClass(className); + } return Comp; }; diff --git a/packages/itwinui-react/src/utils/hooks/useSafeContext.ts b/packages/itwinui-react/src/utils/hooks/useSafeContext.ts index ed86c19c9f3..f3f748b5812 100644 --- a/packages/itwinui-react/src/utils/hooks/useSafeContext.ts +++ b/packages/itwinui-react/src/utils/hooks/useSafeContext.ts @@ -11,7 +11,7 @@ import * as React from 'react'; export const useSafeContext = (context: React.Context) => { const value = React.useContext(context); if (!value) { - throw new Error(`${context.displayName} is undefined`); + throw new Error(`${context.displayName || 'Context'} is undefined`); } return value!; // eslint-disable-line @typescript-eslint/no-non-null-assertion -- we already checked for undefined };