Improve context types (#10510)

This commit is contained in:
Michael Telatynski 2023-04-04 14:01:04 +01:00 committed by GitHub
parent 974dc35c41
commit b77b2df29b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 2 deletions

View File

@ -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;

View File

@ -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";
/**