Conform more of the codebase to strict types (#11191)

This commit is contained in:
Michael Telatynski 2023-07-05 11:53:22 +01:00 committed by GitHub
parent 4044c2aa66
commit 8107f1d271
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 88 additions and 57 deletions

View file

@ -92,7 +92,7 @@ export default class LazyRenderList<T = any> extends React.Component<IProps<T>,
this.state = LazyRenderList.getDerivedStateFromProps(props, {} as IState) as IState;
}
public static getDerivedStateFromProps(props: IProps<unknown>, state: IState): Partial<IState> | null {
public static getDerivedStateFromProps<T>(props: IProps<T>, state: IState): Partial<IState> | null {
const range = LazyRenderList.getVisibleRangeFromProps(props);
const intersectRange = range.expand(props.overflowMargin);
const renderRange = range.expand(props.overflowItems);
@ -105,7 +105,7 @@ export default class LazyRenderList<T = any> extends React.Component<IProps<T>,
return null;
}
private static getVisibleRangeFromProps(props: IProps<unknown>): ItemRange {
private static getVisibleRangeFromProps<T>(props: IProps<T>): ItemRange {
const { items, itemHeight, scrollTop, height } = props;
const length = items ? items.length : 0;
const topCount = Math.min(Math.max(0, Math.floor(scrollTop / itemHeight)), length);

View file

@ -15,6 +15,7 @@ limitations under the License.
*/
import React, { createRef, KeyboardEventHandler } from "react";
import { MatrixError } from "matrix-js-sdk/src/matrix";
import { _t } from "../../../languageHandler";
import withValidation, { IFieldState, IValidationResult } from "./Validation";
@ -209,7 +210,7 @@ export default class RoomAliasField extends React.PureComponent<IProps, IState>
// any server error code will do,
// either it M_NOT_FOUND or the alias is invalid somehow,
// in which case we don't want to show the invalid message
return !!err.errcode;
return err instanceof MatrixError;
}
},
valid: () => _t("This address is available to use"),