Conform more of the codebase to strictNullChecks (#10731)

This commit is contained in:
Michael Telatynski 2023-04-28 09:45:36 +01:00 committed by GitHub
parent 9f8113eabd
commit 1281c0746b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
40 changed files with 147 additions and 119 deletions

View file

@ -14,13 +14,13 @@ See the License for the specific language governing permissions and
limitations under the License.
*/
import { IAuthData } from "matrix-js-sdk/src/interactive-auth";
import { IAuthDict } from "matrix-js-sdk/src/interactive-auth";
import { UIAResponse } from "matrix-js-sdk/src/@types/uia";
import Modal from "../Modal";
import InteractiveAuthDialog, { InteractiveAuthDialogProps } from "../components/views/dialogs/InteractiveAuthDialog";
type FunctionWithUIA<R, A> = (auth?: IAuthData, ...args: A[]) => Promise<UIAResponse<R>>;
type FunctionWithUIA<R, A> = (auth?: IAuthDict | null, ...args: A[]) => Promise<UIAResponse<R>>;
export function wrapRequestWithDialog<R, A = any>(
requestFunction: FunctionWithUIA<R, A>,
@ -29,7 +29,7 @@ export function wrapRequestWithDialog<R, A = any>(
return async function (...args): Promise<R> {
return new Promise((resolve, reject) => {
const boundFunction = requestFunction.bind(opts.matrixClient) as FunctionWithUIA<R, A>;
boundFunction(undefined, ...args)
boundFunction(null, ...args)
.then((res) => resolve(res as R))
.catch((error) => {
if (error.httpStatus !== 401 || !error.data?.flows) {
@ -40,7 +40,7 @@ export function wrapRequestWithDialog<R, A = any>(
Modal.createDialog(InteractiveAuthDialog, {
...opts,
authData: error.data,
makeRequest: (authData?: IAuthData) => boundFunction(authData, ...args),
makeRequest: (authData: IAuthDict | null) => boundFunction(authData, ...args),
onFinished: (success, result) => {
if (success) {
resolve(result as R);

View file

@ -18,7 +18,7 @@ import { Room } from "matrix-js-sdk/src/matrix";
import { LocalRoom, LOCAL_ROOM_ID_PREFIX } from "../../models/LocalRoom";
export function isLocalRoom(roomOrID?: Room | string): boolean {
export function isLocalRoom(roomOrID?: Room | string | null): boolean {
if (typeof roomOrID === "string") {
return roomOrID.startsWith(LOCAL_ROOM_ID_PREFIX);
}