diff --git a/app/soapbox/components/account.tsx b/app/soapbox/components/account.tsx index c31305c54..f86cf8370 100644 --- a/app/soapbox/components/account.tsx +++ b/app/soapbox/components/account.tsx @@ -47,11 +47,17 @@ const InstanceFavicon: React.FC = ({ account, disabled }) => { interface IProfilePopper { condition: boolean, - wrapper: (children: any) => React.ReactElement + wrapper: (children: React.ReactNode) => React.ReactNode + children: React.ReactNode } -const ProfilePopper: React.FC = ({ condition, wrapper, children }): any => - condition ? wrapper(children) : children; +const ProfilePopper: React.FC = ({ condition, wrapper, children }) => { + return ( + <> + {condition ? wrapper(children) : children} + + ); +}; export interface IAccount { account: AccountEntity, diff --git a/app/soapbox/components/autosuggest-textarea.tsx b/app/soapbox/components/autosuggest-textarea.tsx index b1b846c56..1cdc7fa06 100644 --- a/app/soapbox/components/autosuggest-textarea.tsx +++ b/app/soapbox/components/autosuggest-textarea.tsx @@ -30,6 +30,7 @@ interface IAutosuggesteTextarea { onFocus: () => void, onBlur?: () => void, condensed?: boolean, + children: React.ReactNode, } class AutosuggestTextarea extends ImmutablePureComponent { diff --git a/app/soapbox/components/display-name.tsx b/app/soapbox/components/display-name.tsx index 12a28b382..e86ea75ee 100644 --- a/app/soapbox/components/display-name.tsx +++ b/app/soapbox/components/display-name.tsx @@ -16,6 +16,7 @@ interface IDisplayName { account: Account withSuffix?: boolean withDate?: boolean + children?: React.ReactNode } const DisplayName: React.FC = ({ account, children, withSuffix = true, withDate = false }) => { diff --git a/app/soapbox/components/error-boundary.tsx b/app/soapbox/components/error-boundary.tsx index 0440de85b..87f6d749d 100644 --- a/app/soapbox/components/error-boundary.tsx +++ b/app/soapbox/components/error-boundary.tsx @@ -26,7 +26,9 @@ const mapStateToProps = (state: RootState) => { }; }; -type Props = ReturnType; +interface Props extends ReturnType { + children: React.ReactNode +} type State = { hasError: boolean, @@ -213,4 +215,4 @@ class ErrorBoundary extends React.PureComponent { } -export default connect(mapStateToProps)(ErrorBoundary as any); +export default connect(mapStateToProps)(ErrorBoundary); diff --git a/app/soapbox/components/helmet.tsx b/app/soapbox/components/helmet.tsx index 6fa678a04..c7eef876a 100644 --- a/app/soapbox/components/helmet.tsx +++ b/app/soapbox/components/helmet.tsx @@ -15,7 +15,11 @@ const getNotifTotals = (state: RootState): number => { return notifications + reports + approvals; }; -const Helmet: React.FC = ({ children }) => { +interface IHelmet { + children: React.ReactNode +} + +const Helmet: React.FC = ({ children }) => { const instance = useInstance(); const { unreadChatsCount } = useStatContext(); const unreadCount = useAppSelector((state) => getNotifTotals(state) + unreadChatsCount); diff --git a/app/soapbox/components/hover-ref-wrapper.tsx b/app/soapbox/components/hover-ref-wrapper.tsx index bcde02720..e1cb9d5f5 100644 --- a/app/soapbox/components/hover-ref-wrapper.tsx +++ b/app/soapbox/components/hover-ref-wrapper.tsx @@ -18,6 +18,7 @@ interface IHoverRefWrapper { accountId: string, inline?: boolean, className?: string, + children: React.ReactNode, } /** Makes a profile hover card appear when the wrapped element is hovered. */ diff --git a/app/soapbox/components/hover-status-wrapper.tsx b/app/soapbox/components/hover-status-wrapper.tsx index 6f23658a0..558428954 100644 --- a/app/soapbox/components/hover-status-wrapper.tsx +++ b/app/soapbox/components/hover-status-wrapper.tsx @@ -17,6 +17,7 @@ interface IHoverStatusWrapper { statusId: any, inline: boolean, className?: string, + children: React.ReactNode, } /** Makes a status hover card appear when the wrapped element is hovered. */ diff --git a/app/soapbox/components/list.tsx b/app/soapbox/components/list.tsx index 886141811..b135fdf36 100644 --- a/app/soapbox/components/list.tsx +++ b/app/soapbox/components/list.tsx @@ -7,7 +7,11 @@ import { SelectDropdown } from '../features/forms'; import Icon from './icon'; import { HStack, Select } from './ui'; -const List: React.FC = ({ children }) => ( +interface IList { + children: React.ReactNode +} + +const List: React.FC = ({ children }) => (
{children}
); @@ -17,6 +21,7 @@ interface IListItem { onClick?(): void, onSelect?(): void isSelected?: boolean + children?: React.ReactNode } const ListItem: React.FC = ({ label, hint, children, onClick, onSelect, isSelected }) => { diff --git a/app/soapbox/components/modal-root.tsx b/app/soapbox/components/modal-root.tsx index 33d8ee741..b0bbc9c59 100644 --- a/app/soapbox/components/modal-root.tsx +++ b/app/soapbox/components/modal-root.tsx @@ -42,6 +42,7 @@ interface IModalRoot { onCancel?: () => void, onClose: (type?: ModalType) => void, type: ModalType, + children: React.ReactNode, } const ModalRoot: React.FC = ({ children, onCancel, onClose, type }) => { @@ -128,10 +129,10 @@ const ModalRoot: React.FC = ({ children, onCancel, onClose, type }) }); }; - const handleKeyDown = useCallback((e) => { + const handleKeyDown = useCallback((e: KeyboardEvent) => { if (e.key === 'Tab') { const focusable = Array.from(ref.current!.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])')).filter((x) => window.getComputedStyle(x).display !== 'none'); - const index = focusable.indexOf(e.target); + const index = focusable.indexOf(e.target as Element); let element; diff --git a/app/soapbox/components/pull-to-refresh.tsx b/app/soapbox/components/pull-to-refresh.tsx index 7596fabea..829441b37 100644 --- a/app/soapbox/components/pull-to-refresh.tsx +++ b/app/soapbox/components/pull-to-refresh.tsx @@ -7,6 +7,7 @@ interface IPullToRefresh { onRefresh?: () => Promise; refreshingContent?: JSX.Element | string; pullingContent?: JSX.Element | string; + children: React.ReactNode; } /** diff --git a/app/soapbox/components/status-reply-mentions.tsx b/app/soapbox/components/status-reply-mentions.tsx index 8b1ce6dd6..7cc2fe026 100644 --- a/app/soapbox/components/status-reply-mentions.tsx +++ b/app/soapbox/components/status-reply-mentions.tsx @@ -79,6 +79,7 @@ const StatusReplyMentions: React.FC = ({ status, hoverable defaultMessage='Replying to {accounts}' values={{ accounts: , + // @ts-ignore wtf? hover: (children: React.ReactNode) => { if (hoverable) { return ( diff --git a/app/soapbox/components/status.tsx b/app/soapbox/components/status.tsx index 491fcef2b..9ffd9a6d9 100644 --- a/app/soapbox/components/status.tsx +++ b/app/soapbox/components/status.tsx @@ -252,8 +252,10 @@ const Status: React.FC = (props) => { if (hidden) { return (
- {actualStatus.getIn(['account', 'display_name']) || actualStatus.getIn(['account', 'username'])} - {actualStatus.content} + <> + {actualStatus.getIn(['account', 'display_name']) || actualStatus.getIn(['account', 'username'])} + {actualStatus.content} +
); } diff --git a/app/soapbox/components/ui/button/button.tsx b/app/soapbox/components/ui/button/button.tsx index 942ce9df9..b09e8c0e2 100644 --- a/app/soapbox/components/ui/button/button.tsx +++ b/app/soapbox/components/ui/button/button.tsx @@ -66,7 +66,7 @@ const Button = React.forwardRef((props, ref): JSX.El return ; }; - const handleClick = React.useCallback((event) => { + const handleClick: React.MouseEventHandler = React.useCallback((event) => { if (onClick && !disabled) { onClick(event); } diff --git a/app/soapbox/components/ui/card/card.tsx b/app/soapbox/components/ui/card/card.tsx index 8efc0c321..6fc85a39a 100644 --- a/app/soapbox/components/ui/card/card.tsx +++ b/app/soapbox/components/ui/card/card.tsx @@ -45,6 +45,7 @@ interface ICardHeader { backHref?: string, onBackClick?: (event: React.MouseEvent) => void className?: string + children?: React.ReactNode } /** @@ -91,6 +92,8 @@ const CardTitle: React.FC = ({ title }): JSX.Element => ( interface ICardBody { /** Classnames for the
element. */ className?: string + /** Children to appear inside the card. */ + children: React.ReactNode } /** A card's body. */ diff --git a/app/soapbox/components/ui/column/column.tsx b/app/soapbox/components/ui/column/column.tsx index f25990c2f..5ccf3ac42 100644 --- a/app/soapbox/components/ui/column/column.tsx +++ b/app/soapbox/components/ui/column/column.tsx @@ -46,6 +46,8 @@ export interface IColumn { className?: string, /** Ref forwarded to column. */ ref?: React.Ref + /** Children to display in the column. */ + children?: React.ReactNode } /** A backdrop for the main section of the UI. */ diff --git a/app/soapbox/components/ui/form-actions/form-actions.tsx b/app/soapbox/components/ui/form-actions/form-actions.tsx index f1480e07c..222acf1e4 100644 --- a/app/soapbox/components/ui/form-actions/form-actions.tsx +++ b/app/soapbox/components/ui/form-actions/form-actions.tsx @@ -2,8 +2,12 @@ import React from 'react'; import HStack from '../hstack/hstack'; +interface IFormActions { + children: React.ReactNode +} + /** Container element to house form actions. */ -const FormActions: React.FC = ({ children }) => ( +const FormActions: React.FC = ({ children }) => ( {children} diff --git a/app/soapbox/components/ui/form-group/form-group.tsx b/app/soapbox/components/ui/form-group/form-group.tsx index f2b60f6bd..d33c6d2a9 100644 --- a/app/soapbox/components/ui/form-group/form-group.tsx +++ b/app/soapbox/components/ui/form-group/form-group.tsx @@ -14,6 +14,8 @@ interface IFormGroup { hintText?: React.ReactNode, /** Input errors. */ errors?: string[] + /** Elements to display within the FormGroup. */ + children: React.ReactNode } /** Input container with label. Renders the child. */ diff --git a/app/soapbox/components/ui/form/form.tsx b/app/soapbox/components/ui/form/form.tsx index 466825434..519fbecec 100644 --- a/app/soapbox/components/ui/form/form.tsx +++ b/app/soapbox/components/ui/form/form.tsx @@ -5,11 +5,13 @@ interface IForm { onSubmit?: (event: React.FormEvent) => void, /** Class name override for the
element. */ className?: string, + /** Elements to display within the Form. */ + children: React.ReactNode, } /** Form element with custom styles. */ const Form: React.FC = ({ onSubmit, children, ...filteredProps }) => { - const handleSubmit = React.useCallback((event) => { + const handleSubmit: React.FormEventHandler = React.useCallback((event) => { event.preventDefault(); if (onSubmit) { diff --git a/app/soapbox/components/ui/layout/layout.tsx b/app/soapbox/components/ui/layout/layout.tsx index c5c18a6cb..c2e808c9c 100644 --- a/app/soapbox/components/ui/layout/layout.tsx +++ b/app/soapbox/components/ui/layout/layout.tsx @@ -2,10 +2,21 @@ import classNames from 'clsx'; import React from 'react'; import StickyBox from 'react-sticky-box'; -interface LayoutComponent extends React.FC { - Sidebar: React.FC, +interface ISidebar { + children: React.ReactNode +} +interface IAside { + children?: React.ReactNode +} + +interface ILayout { + children: React.ReactNode +} + +interface LayoutComponent extends React.FC { + Sidebar: React.FC, Main: React.FC>, - Aside: React.FC, + Aside: React.FC, } /** Layout container, to hold Sidebar, Main, and Aside. */ @@ -18,7 +29,7 @@ const Layout: LayoutComponent = ({ children }) => ( ); /** Left sidebar container in the UI. */ -const Sidebar: React.FC = ({ children }) => ( +const Sidebar: React.FC = ({ children }) => (
{children} @@ -38,7 +49,7 @@ const Main: React.FC> = ({ children, classN ); /** Right sidebar container in the UI. */ -const Aside: React.FC = ({ children }) => ( +const Aside: React.FC = ({ children }) => (