Skip to content

Commit 80fc099

Browse files
authored
Explicitly specify all children props (matrix-org#10312)
1 parent ad26925 commit 80fc099

32 files changed

+86
-43
lines changed

src/AsyncWrapper.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { ComponentType } from "react";
17+
import React, { ComponentType, PropsWithChildren } from "react";
1818
import { logger } from "matrix-js-sdk/src/logger";
1919

2020
import { _t } from "./languageHandler";
@@ -31,7 +31,7 @@ interface IProps {
3131
}
3232

3333
interface IState {
34-
component?: ComponentType;
34+
component?: ComponentType<PropsWithChildren<any>>;
3535
error?: Error;
3636
}
3737

src/components/structures/AutoHideScrollbar.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616
*/
1717

1818
import classNames from "classnames";
19-
import React, { HTMLAttributes, ReactHTML, WheelEvent } from "react";
19+
import React, { HTMLAttributes, ReactHTML, ReactNode, WheelEvent } from "react";
2020

2121
type DynamicHtmlElementProps<T extends keyof JSX.IntrinsicElements> =
2222
JSX.IntrinsicElements[T] extends HTMLAttributes<{}> ? DynamicElementProps<T> : DynamicElementProps<"div">;
@@ -30,6 +30,7 @@ export type IProps<T extends keyof JSX.IntrinsicElements> = Omit<DynamicHtmlElem
3030
style?: React.CSSProperties;
3131
tabIndex?: number;
3232
wrappedRef?: (ref: HTMLDivElement) => void;
33+
children: ReactNode;
3334
};
3435

3536
export default class AutoHideScrollbar<T extends keyof JSX.IntrinsicElements> extends React.Component<IProps<T>> {

src/components/structures/ContextMenu.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ interface IState {
111111
// Generic ContextMenu Portal wrapper
112112
// all options inside the menu should be of role=menuitem/menuitemcheckbox/menuitemradiobutton and have tabIndex={-1}
113113
// this will allow the ContextMenu to manage its own focus using arrow keys as per the ARIA guidelines.
114-
export default class ContextMenu extends React.PureComponent<IProps, IState> {
114+
export default class ContextMenu extends React.PureComponent<React.PropsWithChildren<IProps>, IState> {
115115
private readonly initialFocus: HTMLElement;
116116

117117
public static defaultProps = {

src/components/structures/MainSplit.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
import React from "react";
18+
import React, { ReactNode } from "react";
1919
import { NumberSize, Resizable } from "re-resizable";
2020
import { Direction } from "re-resizable/lib/resizer";
2121

@@ -25,6 +25,7 @@ interface IProps {
2525
resizeNotifier: ResizeNotifier;
2626
collapsedRhs?: boolean;
2727
panel?: JSX.Element;
28+
children: ReactNode;
2829
}
2930

3031
export default class MainSplit extends React.Component<IProps> {

src/components/structures/ScrollPanel.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ interface IProps {
7474
* of the wrapper
7575
*/
7676
fixedChildren?: ReactNode;
77+
children?: ReactNode;
7778

7879
/* onFillRequest(backwards): a callback which is called on scroll when
7980
* the user nears the start (backwards = true) or end (backwards =

src/components/structures/SpaceHierarchy.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ interface ITileProps {
8181
selected?: boolean;
8282
numChildRooms?: number;
8383
hasPermissions?: boolean;
84+
children?: ReactNode;
8485
onViewRoomClick(): void;
8586
onJoinRoomClick(): Promise<unknown>;
8687
onToggleClick?(): void;

src/components/structures/UserMenu.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { createRef } from "react";
17+
import React, { createRef, ReactNode } from "react";
1818
import { Room } from "matrix-js-sdk/src/models/room";
1919

2020
import { MatrixClientPeg } from "../../MatrixClientPeg";
@@ -54,6 +54,7 @@ import { SDKContext } from "../../contexts/SDKContext";
5454

5555
interface IProps {
5656
isPanelCollapsed: boolean;
57+
children?: ReactNode;
5758
}
5859

5960
type PartialDOMRect = Pick<DOMRect, "width" | "left" | "top" | "height">;

src/components/views/auth/AuthPage.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ See the License for the specific language governing permissions and
1616
limitations under the License.
1717
*/
1818

19-
import React from "react";
19+
import React, { ReactNode } from "react";
2020

2121
import AuthFooter from "./AuthFooter";
2222

23-
export default class AuthPage extends React.PureComponent {
23+
export default class AuthPage extends React.PureComponent<{ children: ReactNode }> {
2424
public render(): React.ReactNode {
2525
return (
2626
<div className="mx_AuthPage">

src/components/views/auth/CompleteSecurityBody.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React from "react";
17+
import React, { ReactNode } from "react";
1818

19-
export default class CompleteSecurityBody extends React.PureComponent {
19+
export default class CompleteSecurityBody extends React.PureComponent<{ children: ReactNode }> {
2020
public render(): React.ReactNode {
2121
return <div className="mx_CompleteSecurityBody">{this.props.children}</div>;
2222
}

src/components/views/avatars/MemberAvatar.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
import React, { useContext } from "react";
18+
import React, { ReactNode, useContext } from "react";
1919
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
2020
import { ResizeMethod } from "matrix-js-sdk/src/@types/partials";
2121

@@ -42,6 +42,7 @@ interface IProps extends Omit<React.ComponentProps<typeof BaseAvatar>, "name" |
4242
style?: any;
4343
forceHistorical?: boolean; // true to deny `useOnlyCurrentProfiles` usage. Default false.
4444
hideTitle?: boolean;
45+
children?: ReactNode;
4546
}
4647

4748
export default function MemberAvatar({

src/components/views/context_menus/IconizedContextMenu.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React from "react";
17+
import React, { ReactNode } from "react";
1818
import classNames from "classnames";
1919

2020
import ContextMenu, {
@@ -36,6 +36,7 @@ interface IOptionListProps {
3636
red?: boolean;
3737
label?: string;
3838
className?: string;
39+
children: ReactNode;
3940
}
4041

4142
interface IOptionProps extends React.ComponentProps<typeof MenuItem> {
@@ -163,7 +164,7 @@ export const IconizedContextMenuOptionList: React.FC<IOptionListProps> = ({
163164
);
164165
};
165166

166-
const IconizedContextMenu: React.FC<IProps> = ({ className, children, compact, ...props }) => {
167+
const IconizedContextMenu: React.FC<React.PropsWithChildren<IProps>> = ({ className, children, compact, ...props }) => {
167168
const classes = classNames("mx_IconizedContextMenu", className, {
168169
mx_IconizedContextMenu_compact: compact,
169170
});

src/components/views/context_menus/WidgetContextMenu.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { useContext } from "react";
17+
import React, { ComponentProps, useContext } from "react";
1818
import { MatrixCapabilities } from "matrix-widget-api";
1919
import { logger } from "matrix-js-sdk/src/logger";
2020
import { ApprovalOpts, WidgetLifecycle } from "@matrix-org/react-sdk-module-api/lib/lifecycles/WidgetLifecycle";
@@ -38,7 +38,7 @@ import { getConfigLivestreamUrl, startJitsiAudioLivestream } from "../../../Live
3838
import { ModuleRunner } from "../../../modules/ModuleRunner";
3939
import { ElementWidget } from "../../../stores/widgets/StopGapWidget";
4040

41-
interface IProps extends React.ComponentProps<typeof IconizedContextMenu> {
41+
interface IProps extends Omit<ComponentProps<typeof IconizedContextMenu>, "children"> {
4242
app: IApp;
4343
userWidget?: boolean;
4444
showUnpin?: boolean;

src/components/views/dialogs/GenericFeatureFeedbackDialog.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { useState } from "react";
17+
import React, { ReactNode, useState } from "react";
1818

1919
import QuestionDialog from "./QuestionDialog";
2020
import { _t } from "../../../languageHandler";
@@ -30,6 +30,7 @@ interface IProps {
3030
subheading: string;
3131
rageshakeLabel: string;
3232
rageshakeData?: Record<string, string>;
33+
children?: ReactNode;
3334
onFinished(sendFeedback?: boolean): void;
3435
}
3536

src/components/views/dialogs/devtools/BaseTool.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { createContext, useState } from "react";
17+
import React, { createContext, ReactNode, useState } from "react";
1818
import { Room } from "matrix-js-sdk/src/models/room";
1919
import classNames from "classnames";
2020

@@ -29,6 +29,7 @@ export interface IDevtoolsProps {
2929

3030
interface IMinProps extends Pick<IDevtoolsProps, "onBack"> {
3131
className?: string;
32+
children?: ReactNode;
3233
}
3334

3435
interface IProps extends IMinProps {

src/components/views/elements/DialogButtons.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ See the License for the specific language governing permissions and
1616
limitations under the License.
1717
*/
1818

19-
import React from "react";
19+
import React, { ReactNode } from "react";
2020

2121
import { _t } from "../../../languageHandler";
2222

@@ -53,9 +53,10 @@ interface IProps {
5353
primaryDisabled?: boolean;
5454

5555
// something to stick next to the buttons, optionally
56-
additive?: React.ReactNode;
56+
additive?: ReactNode;
5757

5858
primaryButtonClass?: string;
59+
children?: ReactNode;
5960
}
6061

6162
/**

src/components/views/elements/ErrorBoundary.tsx

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ import SdkConfig from "../../../SdkConfig";
2525
import BugReportDialog from "../dialogs/BugReportDialog";
2626
import AccessibleButton from "./AccessibleButton";
2727

28+
interface Props {
29+
children: ReactNode;
30+
}
31+
2832
interface IState {
2933
error: Error;
3034
}
@@ -33,8 +37,8 @@ interface IState {
3337
* This error boundary component can be used to wrap large content areas and
3438
* catch exceptions during rendering in the component tree below them.
3539
*/
36-
export default class ErrorBoundary extends React.PureComponent<{}, IState> {
37-
public constructor(props: {}) {
40+
export default class ErrorBoundary extends React.PureComponent<Props, IState> {
41+
public constructor(props: Props) {
3842
super(props);
3943

4044
this.state = {

src/components/views/elements/InfoTooltip.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
import React from "react";
18+
import React, { ReactNode } from "react";
1919
import classNames from "classnames";
2020

2121
import { Alignment } from "./Tooltip";
@@ -32,6 +32,7 @@ interface ITooltipProps {
3232
className?: string;
3333
tooltipClassName?: string;
3434
kind?: InfoTooltipKind;
35+
children?: ReactNode;
3536
}
3637

3738
export default class InfoTooltip extends React.PureComponent<ITooltipProps> {

src/components/views/elements/MiniAvatarUploader.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
import classNames from "classnames";
1818
import { EventType } from "matrix-js-sdk/src/@types/event";
19-
import React, { useContext, useRef, useState, MouseEvent } from "react";
19+
import React, { useContext, useRef, useState, MouseEvent, ReactNode } from "react";
2020

2121
import MatrixClientContext from "../../../contexts/MatrixClientContext";
2222
import RoomContext from "../../../contexts/RoomContext";
@@ -35,6 +35,7 @@ interface IProps {
3535
setAvatarUrl(url: string): Promise<unknown>;
3636
isUserAvatar?: boolean;
3737
onClick?(ev: MouseEvent<HTMLInputElement>): void;
38+
children?: ReactNode;
3839
}
3940

4041
const MiniAvatarUploader: React.FC<IProps> = ({

src/components/views/elements/PersistedElement.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { MutableRefObject } from "react";
17+
import React, { MutableRefObject, ReactNode } from "react";
1818
import ReactDOM from "react-dom";
1919
import { isNullOrUndefined } from "matrix-js-sdk/src/utils";
2020

@@ -58,6 +58,7 @@ interface IProps {
5858

5959
// Handle to manually notify this PersistedElement that it needs to move
6060
moveRef?: MutableRefObject<(() => void) | undefined>;
61+
children: ReactNode;
6162
}
6263

6364
/**

src/components/views/elements/TruncatedList.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ See the License for the specific language governing permissions and
1515
limitations under the License.
1616
*/
1717

18-
import React from "react";
18+
import React, { ReactNode } from "react";
1919

2020
import { _t } from "../../../languageHandler";
2121

@@ -35,6 +35,7 @@ interface IProps {
3535
// A function which will be invoked when an overflow element is required.
3636
// This will be inserted after the children.
3737
createOverflowElement?: (overflowCount: number, totalCount: number) => React.ReactNode;
38+
children?: ReactNode;
3839
}
3940

4041
export default class TruncatedList extends React.Component<IProps> {

src/components/views/messages/TileErrorBoundary.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import { Layout } from "../../../settings/enums/Layout";
3030
interface IProps {
3131
mxEvent: MatrixEvent;
3232
layout: Layout;
33+
children: ReactNode;
3334
}
3435

3536
interface IState {

src/components/views/polls/PollOption.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React from "react";
17+
import React, { ReactNode } from "react";
1818
import classNames from "classnames";
1919
import { PollAnswerSubevent } from "matrix-js-sdk/src/extensible_events_v1/PollStartEvent";
2020

@@ -47,6 +47,7 @@ interface PollOptionProps extends PollOptionContentProps {
4747
isEnded?: boolean;
4848
isChecked?: boolean;
4949
onOptionSelected?: (id: string) => void;
50+
children?: ReactNode;
5051
}
5152

5253
const EndedPollOption: React.FC<Omit<PollOptionProps, "voteCount" | "totalVoteCount">> = ({

src/components/views/right_panel/BaseCard.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ interface IProps {
3535
onKeyDown?(ev: KeyboardEvent): void;
3636
cardState?: any;
3737
ref?: Ref<HTMLDivElement>;
38+
children: ReactNode;
3839
}
3940

4041
interface IGroupProps {
4142
className?: string;
4243
title: string;
44+
children: ReactNode;
4345
}
4446

4547
export const Group: React.FC<IGroupProps> = ({ className, title, children }) => {

src/components/views/right_panel/HeaderButton.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ See the License for the specific language governing permissions and
1818
limitations under the License.
1919
*/
2020

21-
import React from "react";
21+
import React, { ReactNode } from "react";
2222
import classNames from "classnames";
2323

2424
import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
@@ -36,6 +36,7 @@ interface IProps {
3636
name: string;
3737
// Button title
3838
title: string;
39+
children?: ReactNode;
3940
}
4041

4142
// TODO: replace this, the composer buttons and the right panel buttons with a unified representation

0 commit comments

Comments
 (0)