From 0ab476b828e06b9b2f980d97f8cb46a4e6590184 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 12 Sep 2022 11:58:05 +0100
Subject: [PATCH] Upgrade @types (#9261)

* Upgrade @types

* Make typescript happier
---
 package.json                                  | 11 +++-----
 src/components/views/elements/AppTile.tsx     |  4 +--
 src/components/views/elements/Dropdown.tsx    |  2 +-
 src/components/views/elements/Field.tsx       |  2 --
 src/components/views/elements/ReplyChain.tsx  |  2 +-
 .../views/rooms/RoomContextDetails.tsx        | 16 +++++-------
 yarn.lock                                     | 26 +++++++++----------
 7 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/package.json b/package.json
index 5c90e917dd..b4f019f7ed 100644
--- a/package.json
+++ b/package.json
@@ -153,13 +153,13 @@
     "@types/katex": "^0.14.0",
     "@types/lodash": "^4.14.168",
     "@types/modernizr": "^3.5.3",
-    "@types/node": "^14.14.22",
+    "@types/node": "^14.18.28",
     "@types/pako": "^1.0.1",
     "@types/parse5": "^6.0.0",
     "@types/qrcode": "^1.3.5",
-    "@types/react": "17.0.14",
+    "@types/react": "^17.0.49",
     "@types/react-beautiful-dnd": "^13.0.0",
-    "@types/react-dom": "17.0.9",
+    "@types/react-dom": "^17.0.17",
     "@types/react-test-renderer": "^17.0.1",
     "@types/react-transition-group": "^4.4.0",
     "@types/sanitize-html": "^2.3.1",
@@ -205,12 +205,9 @@
     "stylelint": "^14.9.1",
     "stylelint-config-standard": "^26.0.0",
     "stylelint-scss": "^4.2.0",
-    "typescript": "^4.7.4",
+    "typescript": "4.7.4",
     "walk": "^2.3.14"
   },
-  "resolutions": {
-    "@types/react": "17.0.14"
-  },
   "jest": {
     "snapshotSerializers": [
       "enzyme-to-json/serializer"
diff --git a/src/components/views/elements/AppTile.tsx b/src/components/views/elements/AppTile.tsx
index a25e42ad26..552c77666e 100644
--- a/src/components/views/elements/AppTile.tsx
+++ b/src/components/views/elements/AppTile.tsx
@@ -18,7 +18,7 @@ limitations under the License.
 */
 
 import url from 'url';
-import React, { ContextType, createRef, MutableRefObject } from 'react';
+import React, { ContextType, createRef, MutableRefObject, ReactNode } from 'react';
 import classNames from 'classnames';
 import { MatrixCapabilities } from "matrix-widget-api";
 import { Room, RoomEvent } from "matrix-js-sdk/src/models/room";
@@ -666,7 +666,7 @@ export default class AppTile extends React.Component<IProps, IState> {
             );
         }
 
-        const layoutButtons: React.ReactNodeArray = [];
+        const layoutButtons: ReactNode[] = [];
         if (this.props.showLayoutButtons) {
             const isMaximised = WidgetLayoutStore.instance.
                 isInContainer(this.props.room, this.props.app, Container.Center);
diff --git a/src/components/views/elements/Dropdown.tsx b/src/components/views/elements/Dropdown.tsx
index d662a5acff..39124bad0d 100644
--- a/src/components/views/elements/Dropdown.tsx
+++ b/src/components/views/elements/Dropdown.tsx
@@ -300,7 +300,7 @@ export default class Dropdown extends React.Component<DropdownProps, IState> {
     }
 
     private getMenuOptions() {
-        const options = React.Children.map(this.props.children, (child) => {
+        const options = React.Children.map(this.props.children, (child: ReactElement) => {
             const highlighted = this.state.highlightedOption === child.key;
             return (
                 <MenuOption
diff --git a/src/components/views/elements/Field.tsx b/src/components/views/elements/Field.tsx
index 8e4b896efd..59f16caacd 100644
--- a/src/components/views/elements/Field.tsx
+++ b/src/components/views/elements/Field.tsx
@@ -38,8 +38,6 @@ export interface IValidateOpts {
 interface IProps {
     // The field's ID, which binds the input and label together. Immutable.
     id?: string;
-    // The field's type (when used as an <input>). Defaults to "text".
-    type?: string;
     // id of a <datalist> element for suggestions
     list?: string;
     // The field's label string.
diff --git a/src/components/views/elements/ReplyChain.tsx b/src/components/views/elements/ReplyChain.tsx
index 8fd0217d7c..6ecfc91d84 100644
--- a/src/components/views/elements/ReplyChain.tsx
+++ b/src/components/views/elements/ReplyChain.tsx
@@ -81,7 +81,7 @@ export default class ReplyChain extends React.Component<IProps, IState> {
 
     private unmounted = false;
     private room: Room;
-    private blockquoteRef = React.createRef<HTMLElement>();
+    private blockquoteRef = React.createRef<HTMLQuoteElement>();
 
     constructor(props: IProps, context: React.ContextType<typeof RoomContext>) {
         super(props, context);
diff --git a/src/components/views/rooms/RoomContextDetails.tsx b/src/components/views/rooms/RoomContextDetails.tsx
index ea5b11a8ba..ef60117d86 100644
--- a/src/components/views/rooms/RoomContextDetails.tsx
+++ b/src/components/views/rooms/RoomContextDetails.tsx
@@ -15,24 +15,22 @@ limitations under the License.
 */
 
 import { Room } from "matrix-js-sdk/src/matrix";
-import React, { ComponentPropsWithoutRef, ElementType } from "react";
+import React, { HTMLAttributes, ReactHTML } from "react";
 
 import { roomContextDetails } from "../../../utils/i18n-helpers";
 
-type Props<T extends ElementType> = ComponentPropsWithoutRef<T> & {
+type Props<T extends keyof ReactHTML> = HTMLAttributes<T> & {
     component?: T;
     room: Room;
 };
 
-export function RoomContextDetails<T extends ElementType>({ room, component: Component = "div", ...other }: Props<T>) {
+export function RoomContextDetails<T extends keyof ReactHTML>({ room, component, ...other }: Props<T>) {
     const contextDetails = roomContextDetails(room);
     if (contextDetails) {
-        return <Component
-            {...other}
-            aria-label={contextDetails.ariaLabel}
-        >
-            { contextDetails.details }
-        </Component>;
+        return React.createElement(component ?? "div", {
+            ...other,
+            "aria-label": contextDetails.ariaLabel,
+        }, [contextDetails.details]);
     }
 
     return null;
diff --git a/yarn.lock b/yarn.lock
index 56dceb9fff..6af625bf8f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -2133,11 +2133,16 @@
   resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.11.tgz#486e72cfccde88da24e1f23ff1b7d8bfb64e6250"
   integrity sha512-KZhFpSLlmK/sdocfSAjqPETTMd0ug6HIMIAwkwUpU79olnZdQtMxpQP+G1wDzCH7na+FltSIhbaZuKdwZ8RDrw==
 
-"@types/node@^14.14.22", "@types/node@^14.14.31":
+"@types/node@^14.14.31":
   version "14.18.26"
   resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.26.tgz#239e19f8b4ea1a9eb710528061c1d733dc561996"
   integrity sha512-0b+utRBSYj8L7XAp0d+DX7lI4cSmowNaaTkk6/1SKzbKkG+doLuPusB9EOvzLJ8ahJSk03bTLIL6cWaEd4dBKA==
 
+"@types/node@^14.18.28":
+  version "14.18.28"
+  resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.28.tgz#ddb82da2fff476a8e827e8773c84c19d9c235278"
+  integrity sha512-CK2fnrQlIgKlCV3N2kM+Gznb5USlwA1KFX3rJVHmgVk6NJxFPuQ86pAcvKnu37IA4BGlSRz7sEE1lHL1aLZ/eQ==
+
 "@types/normalize-package-data@^2.4.0":
   version "2.4.1"
   resolved "https://registry.yarnpkg.com/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz#d3357479a0fdfdd5907fe67e17e0a85c906e1301"
@@ -2182,14 +2187,7 @@
   dependencies:
     "@types/react" "*"
 
-"@types/react-dom@17.0.9":
-  version "17.0.9"
-  resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.9.tgz#441a981da9d7be117042e1a6fd3dac4b30f55add"
-  integrity sha512-wIvGxLfgpVDSAMH5utdL9Ngm5Owu0VsGmldro3ORLXV8CShrL8awVj06NuEXFQ5xyaYfdca7Sgbk/50Ri1GdPg==
-  dependencies:
-    "@types/react" "*"
-
-"@types/react-dom@<18.0.0":
+"@types/react-dom@<18.0.0", "@types/react-dom@^17.0.17":
   version "17.0.17"
   resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-17.0.17.tgz#2e3743277a793a96a99f1bf87614598289da68a1"
   integrity sha512-VjnqEmqGnasQKV0CWLevqMTXBYG9GbwuE6x3VetERLh0cq2LTptFE73MrQi2S7GkKXCf2GgwItB/melLnxfnsg==
@@ -2220,10 +2218,10 @@
   dependencies:
     "@types/react" "*"
 
-"@types/react@*", "@types/react@17.0.14", "@types/react@^17":
-  version "17.0.14"
-  resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.14.tgz#f0629761ca02945c4e8fea99b8177f4c5c61fb0f"
-  integrity sha512-0WwKHUbWuQWOce61UexYuWTGuGY/8JvtUe/dtQ6lR4sZ3UiylHotJeWpf3ArP9+DSGUoLY3wbU59VyMrJps5VQ==
+"@types/react@*", "@types/react@17.0.49", "@types/react@^17", "@types/react@^17.0.49":
+  version "17.0.49"
+  resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.49.tgz#df87ba4ca8b7942209c3dc655846724539dc1049"
+  integrity sha512-CCBPMZaPhcKkYUTqFs/hOWqKjPxhTEmnZWjlHHgIMop67DsXywf9B5Os9Hz8KSacjNOgIdnZVJamwl232uxoPg==
   dependencies:
     "@types/prop-types" "*"
     "@types/scheduler" "*"
@@ -9033,7 +9031,7 @@ typedarray-to-buffer@^3.1.5:
   dependencies:
     is-typedarray "^1.0.0"
 
-typescript@^4.7.4:
+typescript@4.7.4:
   version "4.7.4"
   resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235"
   integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==