Conform more of the codebase to strictNullChecks
(#10602)
* Conform more of the codebase to `strictNullChecks` * Conform more of the codebase to `strictNullChecks` * Fix types
This commit is contained in:
parent
93858813a3
commit
daad630827
26 changed files with 79 additions and 49 deletions
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { RefObject, useRef, useState } from "react";
|
||||
import React, { useRef, useState } from "react";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { JoinRule } from "matrix-js-sdk/src/@types/partials";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
@ -41,9 +41,9 @@ const CreateSubspaceDialog: React.FC<IProps> = ({ space, onAddExistingSpaceClick
|
|||
|
||||
const [busy, setBusy] = useState<boolean>(false);
|
||||
const [name, setName] = useState("");
|
||||
const spaceNameField = useRef() as RefObject<Field>;
|
||||
const spaceNameField = useRef<Field>(null);
|
||||
const [alias, setAlias] = useState("");
|
||||
const spaceAliasField = useRef() as RefObject<RoomAliasField>;
|
||||
const spaceAliasField = useRef<RoomAliasField>(null);
|
||||
const [avatar, setAvatar] = useState<File | undefined>();
|
||||
const [topic, setTopic] = useState<string>("");
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
|||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React, { useRef, useState, Dispatch, SetStateAction, RefObject } from "react";
|
||||
import React, { useRef, useState, Dispatch, SetStateAction } from "react";
|
||||
import { Room } from "matrix-js-sdk/src/matrix";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
|
||||
|
@ -104,8 +104,8 @@ const ExportDialog: React.FC<IProps> = ({ room, onFinished }) => {
|
|||
} = useExportFormState();
|
||||
|
||||
const [isExporting, setExporting] = useState(false);
|
||||
const sizeLimitRef = useRef() as RefObject<Field>;
|
||||
const messageCountRef = useRef() as RefObject<Field>;
|
||||
const sizeLimitRef = useRef<Field>(null);
|
||||
const messageCountRef = useRef<Field>(null);
|
||||
const [exportProgressText, setExportProgressText] = useState(_t("Processing…"));
|
||||
const [displayCancel, setCancelWarning] = useState(false);
|
||||
const [exportCancelled, setExportCancelled] = useState(false);
|
||||
|
|
|
@ -15,7 +15,7 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import * as React from "react";
|
||||
import { RefObject, SyntheticEvent, useRef, useState } from "react";
|
||||
import { SyntheticEvent, useRef, useState } from "react";
|
||||
|
||||
import { _t, _td } from "../../../languageHandler";
|
||||
import Field from "../elements/Field";
|
||||
|
@ -30,7 +30,7 @@ interface IProps {
|
|||
|
||||
const RegistrationEmailPromptDialog: React.FC<IProps> = ({ onFinished }) => {
|
||||
const [email, setEmail] = useState("");
|
||||
const fieldRef = useRef() as RefObject<Field>;
|
||||
const fieldRef = useRef<Field>(null);
|
||||
|
||||
const onSubmit = async (e: SyntheticEvent): Promise<void> => {
|
||||
e.preventDefault();
|
||||
|
|
|
@ -255,7 +255,7 @@ export default class ReportEventDialog extends React.Component<IProps, IState> {
|
|||
});
|
||||
} else {
|
||||
// Report to homeserver admin through the dedicated Matrix API.
|
||||
await client.reportEvent(ev.getRoomId(), ev.getId(), -100, this.state.reason.trim());
|
||||
await client.reportEvent(ev.getRoomId()!, ev.getId()!, -100, this.state.reason.trim());
|
||||
}
|
||||
|
||||
// if the user should also be ignored, do that
|
||||
|
@ -340,7 +340,7 @@ export default class ReportEventDialog extends React.Component<IProps, IState> {
|
|||
);
|
||||
break;
|
||||
case NonStandardValue.Admin:
|
||||
if (client.isRoomEncrypted(this.props.mxEvent.getRoomId())) {
|
||||
if (client.isRoomEncrypted(this.props.mxEvent.getRoomId()!)) {
|
||||
subtitle = _t(
|
||||
"This room is dedicated to illegal or toxic content " +
|
||||
"or the moderators fail to moderate illegal or toxic content.\n" +
|
||||
|
|
|
@ -288,8 +288,8 @@ interface IDirectoryOpts {
|
|||
}
|
||||
|
||||
const SpotlightDialog: React.FC<IProps> = ({ initialText = "", initialFilter = null, onFinished }) => {
|
||||
const inputRef = useRef() as RefObject<HTMLInputElement>;
|
||||
const scrollContainerRef = useRef() as RefObject<HTMLDivElement>;
|
||||
const inputRef = useRef<HTMLInputElement>(null);
|
||||
const scrollContainerRef = useRef<HTMLDivElement>(null);
|
||||
const cli = MatrixClientPeg.get();
|
||||
const rovingContext = useContext(RovingTabIndexContext);
|
||||
const [query, _setQuery] = useState(initialText);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue