Make more code conform to strict null checks (#10219
* Make more code conform to strict null checks * Fix types * Fix tests * Fix remaining test assertions * Iterate PR
This commit is contained in:
parent
4c79ecf141
commit
76b82b4b2b
130 changed files with 603 additions and 603 deletions
|
@ -32,7 +32,7 @@ interface IProps {
|
|||
|
||||
/* callback to update the value. Called with a single argument: the new
|
||||
* value. */
|
||||
onSubmit?: (value: string) => Promise<{} | void>;
|
||||
onSubmit: (value: string) => Promise<{} | void>;
|
||||
|
||||
/* should the input submit when focus is lost? */
|
||||
blurToSubmit?: boolean;
|
||||
|
@ -40,7 +40,7 @@ interface IProps {
|
|||
|
||||
interface IState {
|
||||
busy: boolean;
|
||||
errorString: string;
|
||||
errorString: string | null;
|
||||
value: string;
|
||||
}
|
||||
|
||||
|
@ -72,7 +72,7 @@ export default class EditableTextContainer extends React.Component<IProps, IStat
|
|||
this.state = {
|
||||
busy: false,
|
||||
errorString: null,
|
||||
value: props.initialValue,
|
||||
value: props.initialValue ?? "",
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -113,7 +113,7 @@ const SSOButton: React.FC<ISSOButtonProps> = ({
|
|||
brandClass = `mx_SSOButton_brand_${brandName}`;
|
||||
icon = <img src={brandIcon} height="24" width="24" alt={brandName} />;
|
||||
} else if (typeof idp?.icon === "string" && idp.icon.startsWith("mxc://")) {
|
||||
const src = mediaFromMxc(idp.icon, matrixClient).getSquareThumbnailHttp(24);
|
||||
const src = mediaFromMxc(idp.icon, matrixClient).getSquareThumbnailHttp(24) ?? undefined;
|
||||
icon = <img src={src} height="24" width="24" alt={idp.name} />;
|
||||
}
|
||||
|
||||
|
|
|
@ -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 { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
import EventIndexPeg from "../../../indexing/EventIndexPeg";
|
||||
|
@ -31,13 +31,13 @@ export enum WarningKind {
|
|||
}
|
||||
|
||||
interface IProps {
|
||||
isRoomEncrypted: boolean;
|
||||
isRoomEncrypted?: boolean;
|
||||
kind: WarningKind;
|
||||
}
|
||||
|
||||
export default function SearchWarning({ isRoomEncrypted, kind }: IProps): JSX.Element {
|
||||
if (!isRoomEncrypted) return null;
|
||||
if (EventIndexPeg.get()) return null;
|
||||
if (!isRoomEncrypted) return <></>;
|
||||
if (EventIndexPeg.get()) return <></>;
|
||||
|
||||
if (EventIndexPeg.error) {
|
||||
return (
|
||||
|
@ -69,8 +69,8 @@ export default function SearchWarning({ isRoomEncrypted, kind }: IProps): JSX.El
|
|||
const brand = SdkConfig.get("brand");
|
||||
const desktopBuilds = SdkConfig.getObject("desktop_builds");
|
||||
|
||||
let text = null;
|
||||
let logo = null;
|
||||
let text: ReactNode | undefined;
|
||||
let logo: JSX.Element | undefined;
|
||||
if (desktopBuilds.get("available")) {
|
||||
logo = <img src={desktopBuilds.get("logo")} />;
|
||||
const buildUrl = desktopBuilds.get("url");
|
||||
|
@ -116,7 +116,7 @@ export default function SearchWarning({ isRoomEncrypted, kind }: IProps): JSX.El
|
|||
// for safety
|
||||
if (!text) {
|
||||
logger.warn("Unknown desktop builds warning kind: ", kind);
|
||||
return null;
|
||||
return <></>;
|
||||
}
|
||||
|
||||
return (
|
||||
|
|
|
@ -26,7 +26,7 @@ interface IResult {
|
|||
text: string;
|
||||
}
|
||||
|
||||
interface IRule<T, D = void> {
|
||||
interface IRule<T, D = undefined> {
|
||||
key: string;
|
||||
final?: boolean;
|
||||
skip?(this: T, data: Data, derivedData: D): boolean;
|
||||
|
@ -90,14 +90,12 @@ export default function withValidation<T = void, D = void>({
|
|||
{ value, focused, allowEmpty = true }: IFieldState,
|
||||
): Promise<IValidationResult> {
|
||||
if (!value && allowEmpty) {
|
||||
return {
|
||||
valid: null,
|
||||
feedback: null,
|
||||
};
|
||||
return {};
|
||||
}
|
||||
|
||||
const data = { value, allowEmpty };
|
||||
const derivedData: D | undefined = deriveData ? await deriveData.call(this, data) : undefined;
|
||||
// We know that if deriveData is set then D will not be undefined
|
||||
const derivedData: D = (await deriveData?.call(this, data)) as D;
|
||||
|
||||
const results: IResult[] = [];
|
||||
let valid = true;
|
||||
|
@ -149,10 +147,7 @@ export default function withValidation<T = void, D = void>({
|
|||
|
||||
// Hide feedback when not focused
|
||||
if (!focused) {
|
||||
return {
|
||||
valid,
|
||||
feedback: null,
|
||||
};
|
||||
return { valid };
|
||||
}
|
||||
|
||||
let details;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue