Comply with noImplicitAny (#9940)
* Stash noImplicitAny work * Stash * Fix imports * Iterate * Fix tests * Delint * Fix tests
This commit is contained in:
parent
ac7f69216e
commit
61a63e47f4
359 changed files with 1621 additions and 1353 deletions
|
@ -26,6 +26,7 @@ import {
|
|||
import { makeBeaconContent, makeBeaconInfoContent } from "matrix-js-sdk/src/content-helpers";
|
||||
import { M_BEACON } from "matrix-js-sdk/src/@types/beacon";
|
||||
import { logger } from "matrix-js-sdk/src/logger";
|
||||
import { Mocked } from "jest-mock";
|
||||
|
||||
import { OwnBeaconStore, OwnBeaconStoreEvent } from "../../src/stores/OwnBeaconStore";
|
||||
import {
|
||||
|
@ -48,7 +49,7 @@ jest.mock("lodash", () => ({
|
|||
jest.useFakeTimers();
|
||||
|
||||
describe("OwnBeaconStore", () => {
|
||||
let geolocation;
|
||||
let geolocation: Mocked<Geolocation>;
|
||||
// 14.03.2022 16:15
|
||||
const now = 1647270879403;
|
||||
const HOUR_MS = 3600000;
|
||||
|
@ -82,7 +83,7 @@ describe("OwnBeaconStore", () => {
|
|||
|
||||
// make fresh rooms every time
|
||||
// as we update room state
|
||||
const makeRoomsWithStateEvents = (stateEvents = []): [Room, Room] => {
|
||||
const makeRoomsWithStateEvents = (stateEvents: MatrixEvent[] = []): [Room, Room] => {
|
||||
const room1 = new Room(room1Id, mockClient, aliceId);
|
||||
const room2 = new Room(room2Id, mockClient, aliceId);
|
||||
|
||||
|
@ -100,7 +101,7 @@ describe("OwnBeaconStore", () => {
|
|||
return store;
|
||||
};
|
||||
|
||||
const expireBeaconAndEmit = (store, beaconInfoEvent: MatrixEvent): void => {
|
||||
const expireBeaconAndEmit = (store: OwnBeaconStore, beaconInfoEvent: MatrixEvent): void => {
|
||||
const beacon = store.getBeaconById(getBeaconInfoIdentifier(beaconInfoEvent));
|
||||
// time travel until beacon is expired
|
||||
advanceDateAndTime(beacon.beaconInfo.timeout + 100);
|
||||
|
@ -112,7 +113,11 @@ describe("OwnBeaconStore", () => {
|
|||
mockClient.emit(BeaconEvent.LivenessChange, false, beacon);
|
||||
};
|
||||
|
||||
const updateBeaconLivenessAndEmit = (store, beaconInfoEvent: MatrixEvent, isLive: boolean): void => {
|
||||
const updateBeaconLivenessAndEmit = (
|
||||
store: OwnBeaconStore,
|
||||
beaconInfoEvent: MatrixEvent,
|
||||
isLive: boolean,
|
||||
): void => {
|
||||
const beacon = store.getBeaconById(getBeaconInfoIdentifier(beaconInfoEvent));
|
||||
// matches original state of event content
|
||||
// except for live property
|
||||
|
|
|
@ -20,7 +20,7 @@ import { EventType } from "matrix-js-sdk/src/@types/event";
|
|||
import { RoomMember } from "matrix-js-sdk/src/models/room-member";
|
||||
import { RoomStateEvent } from "matrix-js-sdk/src/models/room-state";
|
||||
import { defer } from "matrix-js-sdk/src/utils";
|
||||
import { ClientEvent, RoomEvent, MatrixEvent } from "matrix-js-sdk/src/matrix";
|
||||
import { ClientEvent, RoomEvent, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import SpaceStore from "../../src/stores/spaces/SpaceStore";
|
||||
import {
|
||||
|
@ -68,7 +68,7 @@ const space2 = "!space2:server";
|
|||
const space3 = "!space3:server";
|
||||
const space4 = "!space4:server";
|
||||
|
||||
const getUserIdForRoomId = jest.fn((roomId) => {
|
||||
const getUserIdForRoomId = jest.fn((roomId: string) => {
|
||||
return {
|
||||
[dm1]: dm1Partner.userId,
|
||||
[dm2]: dm2Partner.userId,
|
||||
|
@ -97,10 +97,10 @@ describe("SpaceStore", () => {
|
|||
|
||||
const spyDispatcher = jest.spyOn(defaultDispatcher, "dispatch");
|
||||
|
||||
let rooms = [];
|
||||
let rooms: Room[] = [];
|
||||
const mkRoom = (roomId: string) => testUtils.mkRoom(client, roomId, rooms);
|
||||
const mkSpace = (spaceId: string, children: string[] = []) => testUtils.mkSpace(client, spaceId, rooms, children);
|
||||
const viewRoom = (roomId) => defaultDispatcher.dispatch({ action: Action.ViewRoom, room_id: roomId }, true);
|
||||
const viewRoom = (roomId: string) => defaultDispatcher.dispatch({ action: Action.ViewRoom, room_id: roomId }, true);
|
||||
|
||||
const run = async () => {
|
||||
mocked(client).getRoom.mockImplementation((roomId) => rooms.find((room) => room.roomId === roomId));
|
||||
|
@ -785,7 +785,7 @@ describe("SpaceStore", () => {
|
|||
mkSpace(space1, [fav1, room1, space4]);
|
||||
});
|
||||
|
||||
const addChildRoom = (spaceId, childId) => {
|
||||
const addChildRoom = (spaceId: string, childId: string) => {
|
||||
const childEvent = mkEvent({
|
||||
event: true,
|
||||
type: EventType.SpaceChild,
|
||||
|
@ -803,7 +803,7 @@ describe("SpaceStore", () => {
|
|||
client.emit(RoomStateEvent.Events, childEvent, spaceRoom.currentState, undefined);
|
||||
};
|
||||
|
||||
const addMember = (spaceId, user: RoomMember) => {
|
||||
const addMember = (spaceId: string, user: RoomMember) => {
|
||||
const memberEvent = mkEvent({
|
||||
event: true,
|
||||
type: EventType.RoomMember,
|
||||
|
@ -998,8 +998,8 @@ describe("SpaceStore", () => {
|
|||
});
|
||||
|
||||
describe("context switching tests", () => {
|
||||
let dispatcherRef;
|
||||
let currentRoom = null;
|
||||
let dispatcherRef: string;
|
||||
let currentRoom: Room | null = null;
|
||||
|
||||
beforeEach(async () => {
|
||||
[room1, room2, orphan1].forEach(mkRoom);
|
||||
|
|
|
@ -31,7 +31,7 @@ describe("VoiceRecordingStore", () => {
|
|||
const room1Recording = { destroy: jest.fn() } as unknown as VoiceMessageRecording;
|
||||
const room2Recording = { destroy: jest.fn() } as unknown as VoiceMessageRecording;
|
||||
|
||||
const state = {
|
||||
const state: Record<string, VoiceMessageRecording | undefined> = {
|
||||
[room1Id]: room1Recording,
|
||||
[room2Id]: room2Recording,
|
||||
[room3Id]: undefined,
|
||||
|
|
|
@ -13,7 +13,9 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
*/
|
||||
|
||||
import { mocked } from "jest-mock";
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
|
||||
import { SpaceWatcher } from "../../../src/stores/room-list/SpaceWatcher";
|
||||
import type { RoomListStoreClass } from "../../../src/stores/room-list/RoomListStore";
|
||||
|
@ -30,8 +32,8 @@ import DMRoomMap from "../../../src/utils/DMRoomMap";
|
|||
let filter: SpaceFilterCondition = null;
|
||||
|
||||
const mockRoomListStore = {
|
||||
addFilter: (f) => (filter = f),
|
||||
removeFilter: () => (filter = null),
|
||||
addFilter: (f: SpaceFilterCondition) => (filter = f),
|
||||
removeFilter: (): void => (filter = null),
|
||||
} as unknown as RoomListStoreClass;
|
||||
|
||||
const getUserIdForRoomId = jest.fn();
|
||||
|
@ -47,7 +49,7 @@ describe("SpaceWatcher", () => {
|
|||
const store = SpaceStore.instance;
|
||||
const client = mocked(MatrixClientPeg.get());
|
||||
|
||||
let rooms = [];
|
||||
let rooms: Room[] = [];
|
||||
const mkSpaceForRooms = (spaceId: string, children: string[] = []) => mkSpace(client, spaceId, rooms, children);
|
||||
|
||||
const setShowAllRooms = async (value: boolean) => {
|
||||
|
|
|
@ -15,17 +15,20 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import { Room } from "matrix-js-sdk/src/models/room";
|
||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||
|
||||
import { stubClient, mkRoom, mkMessage } from "../../../test-utils";
|
||||
import { mkMessage, mkRoom, stubClient } from "../../../test-utils";
|
||||
import { MatrixClientPeg } from "../../../../src/MatrixClientPeg";
|
||||
import "../../../../src/stores/room-list/RoomListStore";
|
||||
import { RecentAlgorithm } from "../../../../src/stores/room-list/algorithms/tag-sorting/RecentAlgorithm";
|
||||
import { EffectiveMembership } from "../../../../src/utils/membership";
|
||||
import { makeThreadEvent, mkThread } from "../../../test-utils/threads";
|
||||
import { DefaultTagID } from "../../../../src/stores/room-list/models";
|
||||
|
||||
describe("RecentAlgorithm", () => {
|
||||
let algorithm;
|
||||
let cli;
|
||||
let algorithm: RecentAlgorithm;
|
||||
let cli: MatrixClient;
|
||||
|
||||
beforeEach(() => {
|
||||
stubClient();
|
||||
cli = MatrixClientPeg.get();
|
||||
|
@ -102,7 +105,7 @@ describe("RecentAlgorithm", () => {
|
|||
room1.addLiveEvents([evt]);
|
||||
room2.addLiveEvents([evt2]);
|
||||
|
||||
expect(algorithm.sortRooms([room2, room1])).toEqual([room1, room2]);
|
||||
expect(algorithm.sortRooms([room2, room1], DefaultTagID.Untagged)).toEqual([room1, room2]);
|
||||
});
|
||||
|
||||
it("orders rooms without messages first", () => {
|
||||
|
@ -122,7 +125,7 @@ describe("RecentAlgorithm", () => {
|
|||
|
||||
room1.addLiveEvents([evt]);
|
||||
|
||||
expect(algorithm.sortRooms([room2, room1])).toEqual([room2, room1]);
|
||||
expect(algorithm.sortRooms([room2, room1], DefaultTagID.Untagged)).toEqual([room2, room1]);
|
||||
|
||||
const { events } = mkThread({
|
||||
room: room1,
|
||||
|
@ -162,7 +165,7 @@ describe("RecentAlgorithm", () => {
|
|||
});
|
||||
room2.addLiveEvents(events2);
|
||||
|
||||
expect(algorithm.sortRooms([room1, room2])).toEqual([room2, room1]);
|
||||
expect(algorithm.sortRooms([room1, room2], DefaultTagID.Untagged)).toEqual([room2, room1]);
|
||||
|
||||
const threadReply = makeThreadEvent({
|
||||
user: "@bob:matrix.org",
|
||||
|
@ -176,7 +179,7 @@ describe("RecentAlgorithm", () => {
|
|||
});
|
||||
room1.addLiveEvents([threadReply]);
|
||||
|
||||
expect(algorithm.sortRooms([room1, room2])).toEqual([room1, room2]);
|
||||
expect(algorithm.sortRooms([room1, room2], DefaultTagID.Untagged)).toEqual([room1, room2]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,7 @@ import { Room } from "matrix-js-sdk/src/matrix";
|
|||
import SettingsStore from "../../../../src/settings/SettingsStore";
|
||||
import { FILTER_CHANGED } from "../../../../src/stores/room-list/filters/IFilterCondition";
|
||||
import { SpaceFilterCondition } from "../../../../src/stores/room-list/filters/SpaceFilterCondition";
|
||||
import { MetaSpace } from "../../../../src/stores/spaces";
|
||||
import { MetaSpace, SpaceKey } from "../../../../src/stores/spaces";
|
||||
import SpaceStore from "../../../../src/stores/spaces/SpaceStore";
|
||||
|
||||
jest.mock("../../../../src/settings/SettingsStore");
|
||||
|
@ -50,8 +50,8 @@ describe("SpaceFilterCondition", () => {
|
|||
const user2Id = "@u2:server";
|
||||
const user3Id = "@u3:server";
|
||||
const makeMockGetValue =
|
||||
(settings = {}) =>
|
||||
(settingName, space) =>
|
||||
(settings: Record<string, any> = {}) =>
|
||||
(settingName: string, space: SpaceKey) =>
|
||||
settings[settingName]?.[space] || false;
|
||||
|
||||
beforeEach(() => {
|
||||
|
@ -61,7 +61,7 @@ describe("SpaceFilterCondition", () => {
|
|||
SpaceStoreInstanceMock.isRoomInSpace.mockReturnValue(true);
|
||||
});
|
||||
|
||||
const initFilter = (space): SpaceFilterCondition => {
|
||||
const initFilter = (space: SpaceKey): SpaceFilterCondition => {
|
||||
const filter = new SpaceFilterCondition();
|
||||
filter.updateSpace(space);
|
||||
jest.runOnlyPendingTimers();
|
||||
|
|
|
@ -38,7 +38,7 @@ describe("WidgetPermissionStore", () => {
|
|||
type: "m.custom",
|
||||
url: "https://invalid.address.here",
|
||||
});
|
||||
let settings = {}; // key value store
|
||||
let settings: Record<string, any> = {}; // key value store
|
||||
|
||||
beforeEach(() => {
|
||||
settings = {}; // clear settings
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue