Conform more of the codebase to strictNullChecks (#10358

* Conform more of the codebase to `strictNullChecks`

* Fix types

* Iterate

* Iterate
This commit is contained in:
Michael Telatynski 2023-03-13 15:07:20 +00:00 committed by GitHub
parent 41d88ad6ae
commit 503df62191
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
76 changed files with 323 additions and 327 deletions

View file

@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import React from "react";
import React, { ReactNode } from "react";
import MImageBody from "./MImageBody";
import { BLURHASH_FIELD } from "../../../utils/image-media";
@ -33,7 +33,7 @@ export default class MStickerBody extends MImageBody {
// MStickerBody doesn't need a wrapping `<a href=...>`, but it does need extra padding
// which is added by mx_MStickerBody_wrapper
protected wrapImage(contentUrl: string, children: React.ReactNode): JSX.Element {
let onClick = null;
let onClick: React.MouseEventHandler | undefined;
if (!this.state.showImage) {
onClick = this.onClick;
}
@ -46,7 +46,7 @@ export default class MStickerBody extends MImageBody {
}
// Placeholder to show in place of the sticker image if img onLoad hasn't fired yet.
protected getPlaceholder(width: number, height: number): JSX.Element {
protected getPlaceholder(width: number, height: number): ReactNode {
if (this.props.mxEvent.getContent().info?.[BLURHASH_FIELD]) return super.getPlaceholder(width, height);
return (
<img
@ -61,7 +61,7 @@ export default class MStickerBody extends MImageBody {
}
// Tooltip to show on mouse over
protected getTooltip(): JSX.Element {
protected getTooltip(): ReactNode {
const content = this.props.mxEvent && this.props.mxEvent.getContent();
if (!content || !content.body || !content.info || !content.info.w) return null;
@ -74,11 +74,11 @@ export default class MStickerBody extends MImageBody {
}
// Don't show "Download this_file.png ..."
protected getFileBody(): JSX.Element {
protected getFileBody(): ReactNode {
return null;
}
protected getBanner(content: IMediaEventContent): JSX.Element {
protected getBanner(content: IMediaEventContent): ReactNode {
return null; // we don't need a banner, we have a tooltip
}
}