Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit b77b2df

Browse files
authored
Improve context types (#10510)
1 parent 974dc35 commit b77b2df

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/contexts/MatrixClientContext.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ import React, {
2525
} from "react";
2626
import { MatrixClient } from "matrix-js-sdk/src/client";
2727

28-
const MatrixClientContext = createContext<MatrixClient | undefined>(undefined);
28+
// This context is available to components under LoggedInView,
29+
// the context must not be used by components outside a MatrixClientContext tree.
30+
// This assertion allows us to make the type not nullable.
31+
const MatrixClientContext = createContext<MatrixClient>(null as any);
2932
MatrixClientContext.displayName = "MatrixClientContext";
3033
export default MatrixClientContext;
3134

src/contexts/SDKContext.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,10 @@ import {
3838
VoiceBroadcastRecordingsStore,
3939
} from "../voice-broadcast";
4040

41-
export const SDKContext = createContext<SdkContextClass | undefined>(undefined);
41+
// This context is available to components under MatrixChat,
42+
// the context must not be used by components outside a SdkContextClass tree.
43+
// This assertion allows us to make the type not nullable.
44+
export const SDKContext = createContext<SdkContextClass>(null as any);
4245
SDKContext.displayName = "SDKContext";
4346

4447
/**

0 commit comments

Comments
 (0)