diff --git a/src/components/views/dialogs/BaseDialog.tsx b/src/components/views/dialogs/BaseDialog.tsx index 8475921928..94fbd46d94 100644 --- a/src/components/views/dialogs/BaseDialog.tsx +++ b/src/components/views/dialogs/BaseDialog.tsx @@ -94,7 +94,11 @@ export default class BaseDialog extends React.Component { public constructor(props: IProps) { super(props); - this.matrixClient = MatrixClientPeg.get(); + // XXX: The contract on MatrixClientContext says it is only available within a LoggedInView subtree, + // given that modals function outside the MatrixChat React tree this simulates that. We don't want to + // use safeGet as it throwing would mean we cannot use modals whilst the user isn't logged in. + // The longer term solution is to move our ModalManager into the React tree to inherit contexts properly. + this.matrixClient = MatrixClientPeg.get()!; } private onKeyDown = (e: KeyboardEvent | React.KeyboardEvent): void => { diff --git a/src/components/views/dialogs/ScrollableBaseModal.tsx b/src/components/views/dialogs/ScrollableBaseModal.tsx index 88c85053aa..507c97c53f 100644 --- a/src/components/views/dialogs/ScrollableBaseModal.tsx +++ b/src/components/views/dialogs/ScrollableBaseModal.tsx @@ -43,7 +43,11 @@ export default abstract class ScrollableBaseModal< } protected get matrixClient(): MatrixClient { - return MatrixClientPeg.get(); + // XXX: The contract on MatrixClientContext says it is only available within a LoggedInView subtree, + // given that modals function outside the MatrixChat React tree this simulates that. We don't want to + // use safeGet as it throwing would mean we cannot use modals whilst the user isn't logged in. + // The longer term solution is to move our ModalManager into the React tree to inherit contexts properly. + return MatrixClientPeg.get()!; } private onKeyDown = (e: KeyboardEvent | React.KeyboardEvent): void => { diff --git a/tsconfig.json b/tsconfig.json index 300b2aca83..6d58595e5c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,7 +7,7 @@ "module": "commonjs", "moduleResolution": "node", "target": "es2016", - "noImplicitAny": false, + "noImplicitAny": true, "noUnusedLocals": true, "sourceMap": false, "outDir": "./lib", @@ -16,6 +16,7 @@ "lib": ["es2020", "dom", "dom.iterable"], "alwaysStrict": true, "strictBindCallApply": true, + "strictNullChecks": true, "noImplicitThis": true }, "include": [