Upgrade @types (#9261)

* Upgrade @types

* Make typescript happier
This commit is contained in:
Michael Telatynski 2022-09-12 11:58:05 +01:00 committed by GitHub
parent a9f04514fb
commit 0ab476b828
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 27 additions and 36 deletions

View file

@ -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;