Conform more code to strictNullChecks
(#10444
* Conform more code to `strictNullChecks` * Fix tests * Fix tests
This commit is contained in:
parent
ba2608ec74
commit
c225b8ec29
29 changed files with 85 additions and 75 deletions
|
@ -27,17 +27,17 @@ enum Phases {
|
|||
|
||||
interface IProps {
|
||||
onValueChanged?: (value: string, shouldSubmit: boolean) => void;
|
||||
initialValue?: string;
|
||||
label?: string;
|
||||
placeholder?: string;
|
||||
className?: string;
|
||||
initialValue: string;
|
||||
label: string;
|
||||
placeholder: string;
|
||||
className: string;
|
||||
labelClassName?: string;
|
||||
placeholderClassName?: string;
|
||||
placeholderClassName: string;
|
||||
// Overrides blurToSubmit if true
|
||||
blurToCancel?: boolean;
|
||||
// Will cause onValueChanged(value, true) to fire on blur
|
||||
blurToSubmit?: boolean;
|
||||
editable?: boolean;
|
||||
blurToSubmit: boolean;
|
||||
editable: boolean;
|
||||
}
|
||||
|
||||
interface IState {
|
||||
|
@ -109,11 +109,11 @@ export default class EditableText extends React.Component<IProps, IState> {
|
|||
this.value = this.props.initialValue;
|
||||
this.showPlaceholder(!this.value);
|
||||
this.onValueChanged(false);
|
||||
this.editableDiv.current.blur();
|
||||
this.editableDiv.current?.blur();
|
||||
};
|
||||
|
||||
private onValueChanged = (shouldSubmit: boolean): void => {
|
||||
this.props.onValueChanged(this.value, shouldSubmit);
|
||||
this.props.onValueChanged?.(this.value, shouldSubmit);
|
||||
};
|
||||
|
||||
private onKeyDown = (ev: React.KeyboardEvent<HTMLDivElement>): void => {
|
||||
|
@ -171,7 +171,7 @@ export default class EditableText extends React.Component<IProps, IState> {
|
|||
|
||||
private onFinish = (
|
||||
ev: React.KeyboardEvent<HTMLDivElement> | React.FocusEvent<HTMLDivElement>,
|
||||
shouldSubmit?: boolean,
|
||||
shouldSubmit = false,
|
||||
): void => {
|
||||
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
||||
const self = this;
|
||||
|
|
|
@ -187,8 +187,8 @@ export default class EventListSummary extends React.Component<IProps> {
|
|||
|
||||
let transition = t;
|
||||
|
||||
if (i < transitions.length - 1 && modMap[t] && modMap[t].after === t2) {
|
||||
transition = modMap[t].newTransition;
|
||||
if (i < transitions.length - 1 && modMap[t] && modMap[t]!.after === t2) {
|
||||
transition = modMap[t]!.newTransition;
|
||||
i++;
|
||||
}
|
||||
|
||||
|
@ -380,7 +380,7 @@ export default class EventListSummary extends React.Component<IProps> {
|
|||
return res ?? null;
|
||||
}
|
||||
|
||||
private static getTransitionSequence(events: IUserEvents[]): TransitionType[] {
|
||||
private static getTransitionSequence(events: IUserEvents[]): Array<TransitionType | null> {
|
||||
return events.map(EventListSummary.getTransition);
|
||||
}
|
||||
|
||||
|
|
|
@ -148,6 +148,7 @@ export default class ReplyChain extends React.Component<IProps, IState> {
|
|||
private async getNextEvent(ev: MatrixEvent): Promise<MatrixEvent | null> {
|
||||
try {
|
||||
const inReplyToEventId = getParentEventId(ev);
|
||||
if (!inReplyToEventId) return null;
|
||||
return await this.getEvent(inReplyToEventId);
|
||||
} catch (e) {
|
||||
return null;
|
||||
|
@ -196,7 +197,7 @@ export default class ReplyChain extends React.Component<IProps, IState> {
|
|||
};
|
||||
|
||||
private getReplyChainColorClass(ev: MatrixEvent): string {
|
||||
return getUserNameColorClass(ev.getSender()).replace("Username", "ReplyChain");
|
||||
return getUserNameColorClass(ev.getSender()!).replace("Username", "ReplyChain");
|
||||
}
|
||||
|
||||
public render(): React.ReactNode {
|
||||
|
@ -231,8 +232,8 @@ export default class ReplyChain extends React.Component<IProps, IState> {
|
|||
pill: (
|
||||
<Pill
|
||||
type={PillType.UserMention}
|
||||
room={room}
|
||||
url={makeUserPermalink(ev.getSender())}
|
||||
room={room ?? undefined}
|
||||
url={makeUserPermalink(ev.getSender()!)}
|
||||
shouldShowPillAvatar={SettingsStore.getValue("Pill.shouldShowPillAvatar")}
|
||||
/>
|
||||
),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue