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

Commit

Permalink
Improve context types (#10510)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Apr 4, 2023
1 parent 974dc35 commit b77b2df
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/contexts/MatrixClientContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ import React, {
} from "react";
import { MatrixClient } from "matrix-js-sdk/src/client";

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

Expand Down
5 changes: 4 additions & 1 deletion src/contexts/SDKContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ import {
VoiceBroadcastRecordingsStore,
} from "../voice-broadcast";

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

/**
Expand Down

0 comments on commit b77b2df

Please sign in to comment.