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

Improve context types #10510

Merged
merged 3 commits into from
Apr 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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