You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-08-07 21:23:00 +03:00
Comply with noImplicitAny (#9940)
* Stash noImplicitAny work * Stash * Fix imports * Iterate * Fix tests * Delint * Fix tests
This commit is contained in:
committed by
GitHub
parent
ac7f69216e
commit
61a63e47f4
@@ -21,7 +21,7 @@ import { Key } from "../../../../src/Keyboard";
|
||||
import { mockPlatformPeg, unmockPlatformPeg } from "../../../test-utils/platform";
|
||||
import { KeyboardKey, KeyboardShortcut } from "../../../../src/components/views/settings/KeyboardShortcut";
|
||||
|
||||
const renderKeyboardShortcut = (Component, props?) => {
|
||||
const renderKeyboardShortcut = (Component: React.FunctionComponentFactory<any>, props: Record<string, any>) => {
|
||||
return render(<Component {...props} />).container;
|
||||
};
|
||||
|
||||
|
@@ -22,6 +22,7 @@ import {
|
||||
MatrixEvent,
|
||||
Room,
|
||||
NotificationCountType,
|
||||
PushRuleActionName,
|
||||
} from "matrix-js-sdk/src/matrix";
|
||||
import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
|
||||
import { act } from "react-dom/test-utils";
|
||||
@@ -38,15 +39,14 @@ jest.mock("matrix-js-sdk/src/logger");
|
||||
// Avoid indirectly importing any eagerly created stores that would require extra setup
|
||||
jest.mock("../../../../src/Notifier");
|
||||
|
||||
const masterRule = {
|
||||
actions: ["dont_notify"],
|
||||
const masterRule: IPushRule = {
|
||||
actions: [PushRuleActionName.DontNotify],
|
||||
conditions: [],
|
||||
default: true,
|
||||
enabled: false,
|
||||
rule_id: RuleId.Master,
|
||||
};
|
||||
// eslint-disable-next-line max-len
|
||||
const oneToOneRule = {
|
||||
const oneToOneRule: IPushRule = {
|
||||
conditions: [
|
||||
{ kind: "room_member_count", is: "2" },
|
||||
{ kind: "event_match", key: "type", pattern: "m.room.message" },
|
||||
@@ -56,8 +56,7 @@ const oneToOneRule = {
|
||||
default: true,
|
||||
enabled: true,
|
||||
} as IPushRule;
|
||||
// eslint-disable-next-line max-len
|
||||
const encryptedOneToOneRule = {
|
||||
const encryptedOneToOneRule: IPushRule = {
|
||||
conditions: [
|
||||
{ kind: "room_member_count", is: "2" },
|
||||
{ kind: "event_match", key: "type", pattern: "m.room.encrypted" },
|
||||
@@ -67,15 +66,13 @@ const encryptedOneToOneRule = {
|
||||
default: true,
|
||||
enabled: true,
|
||||
} as IPushRule;
|
||||
// eslint-disable-next-line max-len
|
||||
const encryptedGroupRule = {
|
||||
const encryptedGroupRule: IPushRule = {
|
||||
conditions: [{ kind: "event_match", key: "type", pattern: "m.room.encrypted" }],
|
||||
actions: ["dont_notify"],
|
||||
rule_id: ".m.rule.encrypted",
|
||||
default: true,
|
||||
enabled: true,
|
||||
} as IPushRule;
|
||||
// eslint-disable-next-line max-len
|
||||
const pushRules: IPushRules = {
|
||||
global: {
|
||||
underride: [
|
||||
@@ -367,7 +364,7 @@ describe("<Notifications />", () => {
|
||||
|
||||
it("toggles and sets settings correctly", async () => {
|
||||
await getComponentAndWait();
|
||||
let audioNotifsToggle;
|
||||
let audioNotifsToggle: HTMLDivElement;
|
||||
|
||||
const update = () => {
|
||||
audioNotifsToggle = screen
|
||||
|
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
import { fireEvent, render } from "@testing-library/react";
|
||||
import { PUSHER_ENABLED } from "matrix-js-sdk/src/@types/event";
|
||||
|
||||
@@ -28,11 +28,10 @@ describe("<DeviceDetails />", () => {
|
||||
isVerified: false,
|
||||
deviceType: DeviceType.Unknown,
|
||||
};
|
||||
const defaultProps = {
|
||||
const defaultProps: ComponentProps<typeof DeviceDetails> = {
|
||||
device: baseDevice,
|
||||
pusher: null,
|
||||
isSigningOut: false,
|
||||
isLoading: false,
|
||||
onSignOutDevice: jest.fn(),
|
||||
saveDeviceName: jest.fn(),
|
||||
setPushNotifications: jest.fn(),
|
||||
|
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import React from "react";
|
||||
import React, { ComponentProps } from "react";
|
||||
import { act, fireEvent, render } from "@testing-library/react";
|
||||
|
||||
import { FilteredDeviceList } from "../../../../../src/components/views/settings/devices/FilteredDeviceList";
|
||||
@@ -59,13 +59,12 @@ describe("<FilteredDeviceList />", () => {
|
||||
last_seen_ts: Date.now() - MS_DAY * 100,
|
||||
deviceType: DeviceType.Unknown,
|
||||
};
|
||||
const defaultProps = {
|
||||
const defaultProps: ComponentProps<typeof FilteredDeviceList> = {
|
||||
onFilterChange: jest.fn(),
|
||||
onDeviceExpandToggle: jest.fn(),
|
||||
onSignOutDevices: jest.fn(),
|
||||
saveDeviceName: jest.fn(),
|
||||
setPushNotifications: jest.fn(),
|
||||
setPusherEnabled: jest.fn(),
|
||||
setSelectedDeviceIds: jest.fn(),
|
||||
localNotificationSettings: new Map(),
|
||||
expandedDeviceIds: [],
|
||||
|
@@ -28,7 +28,7 @@ jest.mock("matrix-js-sdk/src/rendezvous/channels");
|
||||
|
||||
const mockedFlow = jest.fn();
|
||||
|
||||
jest.mock("../../../../../src/components/views/auth/LoginWithQRFlow", () => (props) => {
|
||||
jest.mock("../../../../../src/components/views/auth/LoginWithQRFlow", () => (props: Record<string, any>) => {
|
||||
mockedFlow(props);
|
||||
return <div />;
|
||||
});
|
||||
|
@@ -14,6 +14,8 @@ See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { UIAFlow } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { deleteDevicesWithInteractiveAuth } from "../../../../../src/components/views/settings/devices/deleteDevices";
|
||||
import Modal from "../../../../../src/Modal";
|
||||
import { getMockClientWithEventEmitter, mockClientMethodsUser } from "../../../../test-utils";
|
||||
@@ -28,7 +30,7 @@ describe("deleteDevices()", () => {
|
||||
|
||||
const modalSpy = jest.spyOn(Modal, "createDialog");
|
||||
|
||||
const interactiveAuthError = { httpStatus: 401, data: { flows: [] } };
|
||||
const interactiveAuthError = { httpStatus: 401, data: { flows: [] as UIAFlow[] } };
|
||||
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
|
@@ -46,7 +46,7 @@ describe("RolesRoomSettingsTab", () => {
|
||||
});
|
||||
|
||||
describe("Element Call", () => {
|
||||
const mockPowerLevels = (events): void => {
|
||||
const mockPowerLevels = (events: Record<string, number>): void => {
|
||||
jest.spyOn(room.currentState, "getStateEvents").mockReturnValue({
|
||||
getContent: () => ({
|
||||
events,
|
||||
|
@@ -24,7 +24,7 @@ import { mockPlatformPeg } from "../../../../../test-utils/platform";
|
||||
const PATH_TO_KEYBOARD_SHORTCUTS = "../../../../../../src/accessibility/KeyboardShortcuts";
|
||||
const PATH_TO_KEYBOARD_SHORTCUT_UTILS = "../../../../../../src/accessibility/KeyboardShortcutUtils";
|
||||
|
||||
const mockKeyboardShortcuts = (override) => {
|
||||
const mockKeyboardShortcuts = (override: Record<string, any>) => {
|
||||
jest.doMock(PATH_TO_KEYBOARD_SHORTCUTS, () => {
|
||||
const original = jest.requireActual(PATH_TO_KEYBOARD_SHORTCUTS);
|
||||
return {
|
||||
@@ -34,7 +34,7 @@ const mockKeyboardShortcuts = (override) => {
|
||||
});
|
||||
};
|
||||
|
||||
const mockKeyboardShortcutUtils = (override) => {
|
||||
const mockKeyboardShortcutUtils = (override: Record<string, any>) => {
|
||||
jest.doMock(PATH_TO_KEYBOARD_SHORTCUT_UTILS, () => {
|
||||
const original = jest.requireActual(PATH_TO_KEYBOARD_SHORTCUT_UTILS);
|
||||
return {
|
||||
@@ -68,7 +68,7 @@ describe("KeyboardUserSettingsTab", () => {
|
||||
},
|
||||
});
|
||||
mockKeyboardShortcutUtils({
|
||||
getKeyboardShortcutValue: (name) => {
|
||||
getKeyboardShortcutValue: (name: string) => {
|
||||
switch (name) {
|
||||
case "keybind1":
|
||||
return {
|
||||
@@ -88,7 +88,7 @@ describe("KeyboardUserSettingsTab", () => {
|
||||
}
|
||||
}
|
||||
},
|
||||
getKeyboardShortcutDisplayName: (name) => {
|
||||
getKeyboardShortcutDisplayName: (name: string) => {
|
||||
switch (name) {
|
||||
case "keybind1":
|
||||
return "Cancel replying to a message";
|
||||
|
@@ -927,7 +927,7 @@ describe("<SessionManagerTab />", () => {
|
||||
// get a handle for resolving the delete call
|
||||
// because promise flushing after the confirm modal is resolving this too
|
||||
// and we want to test the loading state here
|
||||
let resolveDeleteRequest;
|
||||
let resolveDeleteRequest: (v?: IAuthData) => void;
|
||||
mockClient.deleteMultipleDevices.mockImplementation(() => {
|
||||
const promise = new Promise<IAuthData>((resolve) => {
|
||||
resolveDeleteRequest = resolve;
|
||||
|
Reference in New Issue
Block a user