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

Commit 3317b60

Browse files
authored
Improve typing around wrapInMatrixClientContext (#8130)
1 parent 8f1e97b commit 3317b60

File tree

3 files changed

+5
-11
lines changed

3 files changed

+5
-11
lines changed

test/components/views/spaces/SpaceSettingsVisibilityTab-test.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ describe('<SpaceSettingsVisibilityTab />', () => {
7070
const wrapper = renderIntoDocument<HTMLSpanElement>(
7171
// wrap in element so renderIntoDocument can render functional component
7272
<span>
73-
{ /* @ts-ignore */ }
7473
<SpaceSettingsVisibilityTab {...defaultProps} {...props} />
7574
</span>,
7675
) as HTMLSpanElement;

test/components/views/voip/VoiceChannelRadio-test.tsx

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ describe("VoiceChannelRadio", () => {
7979
});
8080

8181
it("shows when connecting voice", async () => {
82-
// @ts-ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
8382
const radio = mount(<VoiceChannelRadio />);
8483
expect(radio.children().children().exists()).toEqual(false);
8584

@@ -90,7 +89,6 @@ describe("VoiceChannelRadio", () => {
9089

9190
it("hides when disconnecting voice", () => {
9291
VoiceChannelStore.instance.connect("!1:example.org");
93-
// @ts-ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
9492
const radio = mount(<VoiceChannelRadio />);
9593
expect(radio.children().children().exists()).toEqual(true);
9694

@@ -102,7 +100,6 @@ describe("VoiceChannelRadio", () => {
102100
describe("disconnect button", () => {
103101
it("works", () => {
104102
VoiceChannelStore.instance.connect("!1:example.org");
105-
// @ts-ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
106103
const radio = mount(<VoiceChannelRadio />);
107104

108105
act(() => {
@@ -115,7 +112,6 @@ describe("VoiceChannelRadio", () => {
115112
describe("video button", () => {
116113
it("works", () => {
117114
VoiceChannelStore.instance.connect("!1:example.org");
118-
// @ts-ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
119115
const radio = mount(<VoiceChannelRadio />);
120116

121117
act(() => {
@@ -133,7 +129,6 @@ describe("VoiceChannelRadio", () => {
133129
describe("audio button", () => {
134130
it("works", () => {
135131
VoiceChannelStore.instance.connect("!1:example.org");
136-
// @ts-ignore - TS doesn't like mounting this for some reason, but is fine with it elsewhere
137132
const radio = mount(<VoiceChannelRadio />);
138133

139134
act(() => {

test/test-utils/wrappers.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,16 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
import React, { RefCallback } from "react";
17+
import React, { RefCallback, ComponentType } from "react";
1818
import { MatrixClient } from "matrix-js-sdk/src/matrix";
1919

2020
import { MatrixClientPeg as peg } from '../../src/MatrixClientPeg';
2121
import MatrixClientContext from "../../src/contexts/MatrixClientContext";
2222

23-
type WrapperType<T> = React.Component<{ wrappedRef?: RefCallback<T> }>;
23+
type WrapperProps<T> = { wrappedRef?: RefCallback<ComponentType<T>> } & T;
2424

25-
export function wrapInMatrixClientContext<T>(WrappedComponent): WrapperType<T> {
26-
class Wrapper extends React.Component<{ wrappedRef?: RefCallback<T> }> {
25+
export function wrapInMatrixClientContext<T>(WrappedComponent: ComponentType<T>): ComponentType<WrapperProps<T>> {
26+
class Wrapper extends React.Component<WrapperProps<T>> {
2727
_matrixClient: MatrixClient;
2828
constructor(props) {
2929
super(props);
@@ -37,5 +37,5 @@ export function wrapInMatrixClientContext<T>(WrappedComponent): WrapperType<T> {
3737
</MatrixClientContext.Provider>;
3838
}
3939
}
40-
return Wrapper as unknown as WrapperType<T>;
40+
return Wrapper;
4141
}

0 commit comments

Comments
 (0)