Skip to content

Commit f9372a3

Browse files
committed
Make tsc happy
1 parent d21eb5a commit f9372a3

File tree

21 files changed

+117
-71
lines changed

21 files changed

+117
-71
lines changed

apps/desktop/hak/tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
"compilerOptions": {
3-
"moduleResolution": "node",
3+
"moduleResolution": "node16",
4+
"module": "Node16",
45
"esModuleInterop": true,
56
"target": "es2022",
67
"sourceMap": false,

apps/desktop/playwright/element-desktop-test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ import { PassThrough } from "node:stream";
1717
* A PassThrough stream that captures all data written to it.
1818
*/
1919
class CapturedPassThrough extends PassThrough {
20-
private _chunks = [];
20+
private _chunks: any[] = [];
2121

2222
public constructor() {
2323
super();
2424
super.on("data", this.onData);
2525
}
2626

27-
private onData = (chunk): void => {
27+
private onData = (chunk: any): void => {
2828
this._chunks.push(chunk);
2929
};
3030

apps/desktop/playwright/tsconfig.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
22
"compilerOptions": {
33
"resolveJsonModule": true,
4-
"moduleResolution": "node",
4+
"moduleResolution": "bundler",
55
"esModuleInterop": true,
66
"target": "es2022",
7-
"module": "es2022",
8-
"lib": ["es2022", "dom"],
7+
"module": "ESNext",
8+
"lib": ["es2024", "dom", "dom.iterable"],
9+
"strictNullChecks": false,
910
"types": ["node"]
1011
},
1112
"include": ["**/*.ts"]

apps/web/playwright/e2e/audio-player/audio-player.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
88
*/
99

1010
import type { Locator, Page } from "@playwright/test";
11-
import { test, expect } from "../../element-web-test";
11+
import { test, expect, type ExtendedToMatchScreenshotOptions } from "../../element-web-test";
1212
import { SettingLevel } from "../../../src/settings/SettingLevel";
1313
import { Layout } from "../../../src/settings/enums/Layout";
1414
import { type ElementAppPage } from "../../pages/ElementAppPage";
@@ -94,7 +94,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
9494
// Assert that rendering of the player settled and the play button is visible before taking a snapshot
9595
await checkPlayerVisibility(ircTile);
9696

97-
const screenshotOptions = {
97+
const screenshotOptions: ExtendedToMatchScreenshotOptions = {
9898
css: `
9999
/* The timestamp is of inconsistent width depending on the time the test runs at */
100100
.mx_MessageTimestamp {
@@ -120,7 +120,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
120120
};
121121

122122
// Take a snapshot of mx_EventTile_last on IRC layout
123-
screenshotOptions.clip = await page.locator(".mx_EventTile_last").boundingBox();
123+
screenshotOptions.clip = (await page.locator(".mx_EventTile_last").boundingBox()) ?? undefined;
124124
await scrollToBottomOfTimeline(page);
125125
await expect(page).toMatchScreenshot(`${detail.replaceAll(" ", "-")}-irc-layout.png`, screenshotOptions);
126126

@@ -129,7 +129,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
129129
const groupTile = page.locator(".mx_EventTile_last[data-layout='group']");
130130
await groupTile.locator(".mx_MessageTimestamp").click();
131131
await checkPlayerVisibility(groupTile);
132-
screenshotOptions.clip = await page.locator(".mx_EventTile_last").boundingBox();
132+
screenshotOptions.clip = (await page.locator(".mx_EventTile_last").boundingBox()) ?? undefined;
133133
await scrollToBottomOfTimeline(page);
134134
await expect(page).toMatchScreenshot(`${detail.replaceAll(" ", "-")}-group-layout.png`, screenshotOptions);
135135

@@ -138,7 +138,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
138138
const bubbleTile = page.locator(".mx_EventTile_last[data-layout='bubble']");
139139
await bubbleTile.locator(".mx_MessageTimestamp").click();
140140
await checkPlayerVisibility(bubbleTile);
141-
screenshotOptions.clip = await page.locator(".mx_EventTile_last").boundingBox();
141+
screenshotOptions.clip = (await page.locator(".mx_EventTile_last").boundingBox()) ?? undefined;
142142
await scrollToBottomOfTimeline(page);
143143
await expect(page).toMatchScreenshot(`${detail.replaceAll(" ", "-")}-bubble-layout.png`, screenshotOptions);
144144
};

apps/web/playwright/e2e/crypto/crypto.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const bobJoin = async (page: Page, bob: Bot) => {
4444
const bobRooms = cli.getRooms();
4545
if (!bobRooms.length) {
4646
await new Promise<void>((resolve) => {
47-
const onMembership = (_event) => {
47+
const onMembership = () => {
4848
cli.off(window.matrixcs.RoomMemberEvent.Membership, onMembership);
4949
resolve();
5050
};

apps/web/playwright/e2e/crypto/decryption-failure-messages.spec.ts

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
66
Please see LICENSE files in the repository root for full details.
77
*/
88

9-
import type { EmittedEvents, Preset } from "matrix-js-sdk/src/matrix";
9+
import type { Preset, RoomMemberEvent, RoomStateEvent } from "matrix-js-sdk/src/matrix";
1010
import { expect, test } from "../../element-web-test";
1111
import {
1212
createRoom,
@@ -122,7 +122,7 @@ test.describe("Cryptography", function () {
122122
const roomId = await bob.evaluate(
123123
async (client, { alice }) => {
124124
const encryptionStatePromise = new Promise<void>((resolve) => {
125-
client.on("RoomState.events" as EmittedEvents, (event, _state, _lastStateEvent) => {
125+
client.on("RoomState.events" as RoomStateEvent.Events, (event, _state, _lastStateEvent) => {
126126
if (event.getType() === "m.room.encryption") {
127127
resolve();
128128
}
@@ -253,11 +253,14 @@ test.describe("Cryptography", function () {
253253

254254
// invite Alice
255255
const inviteAlicePromise = new Promise<void>((resolve) => {
256-
client.on("RoomMember.membership" as EmittedEvents, (_event, member, _oldMembership?) => {
257-
if (member.userId === alice.userId && member.membership === "invite") {
258-
resolve();
259-
}
260-
});
256+
client.on(
257+
"RoomMember.membership" as RoomMemberEvent.Membership,
258+
(_event, member, _oldMembership?) => {
259+
if (member.userId === alice.userId && member.membership === "invite") {
260+
resolve();
261+
}
262+
},
263+
);
261264
});
262265
await client.invite(roomId, alice.userId);
263266
// wait for the invite to come back so that we encrypt to Alice
@@ -271,11 +274,14 @@ test.describe("Cryptography", function () {
271274

272275
// kick Alice
273276
const kickAlicePromise = new Promise<void>((resolve) => {
274-
client.on("RoomMember.membership" as EmittedEvents, (_event, member, _oldMembership?) => {
275-
if (member.userId === alice.userId && member.membership === "leave") {
276-
resolve();
277-
}
278-
});
277+
client.on(
278+
"RoomMember.membership" as RoomMemberEvent.Membership,
279+
(_event, member, _oldMembership?) => {
280+
if (member.userId === alice.userId && member.membership === "leave") {
281+
resolve();
282+
}
283+
},
284+
);
279285
});
280286
await client.kick(roomId, alice.userId);
281287
await kickAlicePromise;

apps/web/playwright/e2e/crypto/dehydration.spec.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -166,13 +166,9 @@ async function getDehydratedDeviceIds(client: Client): Promise<string[]> {
166166
return await client.evaluate(async (client) => {
167167
const userId = client.getUserId();
168168
const devices = await client.getCrypto().getUserDeviceInfo([userId]);
169-
return Array.from(
170-
devices
171-
.get(userId)
172-
.values()
173-
.filter((d) => d.dehydrated)
174-
.map((d) => d.deviceId),
175-
);
169+
return Array.from(devices.get(userId).values())
170+
.filter((d) => d.dehydrated)
171+
.map((d) => d.deviceId);
176172
});
177173
}
178174

apps/web/playwright/e2e/crypto/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -579,8 +579,8 @@ export async function deleteCachedSecrets(page: Page) {
579579
await page.evaluate(async () => {
580580
const removeCachedSecrets = new Promise((resolve) => {
581581
const request = window.indexedDB.open("matrix-js-sdk::matrix-sdk-crypto");
582-
request.onsuccess = (event: Event & { target: { result: IDBDatabase } }) => {
583-
const db = event.target.result;
582+
request.onsuccess = function (this: IDBRequest) {
583+
const db = this.result as IDBDatabase;
584584
const request = db.transaction("core", "readwrite").objectStore("core").delete("private_identity");
585585
request.onsuccess = () => {
586586
db.close();

apps/web/playwright/e2e/read-receipts/read-receipts.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
77
*/
88

99
import type { JSHandle } from "@playwright/test";
10-
import type { MatrixEvent, ISendEventResponse, ReceiptType } from "matrix-js-sdk/src/matrix";
10+
import type { MatrixEvent, ISendEventResponse, ReceiptType, RelationType } from "matrix-js-sdk/src/matrix";
1111
import { expect } from "../../element-web-test";
1212
import { type ElementAppPage } from "../../pages/ElementAppPage";
1313
import { type Bot } from "../../pages/bot";
@@ -47,7 +47,7 @@ test.describe("Read receipts", { tag: "@mergequeue" }, () => {
4747
getId: () => eventResponse.event_id,
4848
threadRootId,
4949
getTs: () => 1,
50-
isRelation: (relType) => {
50+
isRelation: (relType: RelationType) => {
5151
return !relType || relType === "m.thread";
5252
},
5353
} as any as MatrixEvent;

apps/web/playwright/e2e/timeline/timeline.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
77
*/
88

99
import type { Locator, Page } from "@playwright/test";
10-
import type { ISendEventResponse, EventType, MsgType } from "matrix-js-sdk/src/matrix";
10+
import type { ISendEventResponse, EventType, MsgType, IContent } from "matrix-js-sdk/src/matrix";
1111
import { test, expect } from "../../element-web-test";
1212
import { SettingLevel } from "../../../src/settings/SettingLevel";
1313
import { Layout } from "../../../src/settings/enums/Layout";
@@ -50,11 +50,9 @@ const expectAvatar = async (cli: Client, e: Locator, avatarUrl: string): Promise
5050
};
5151

5252
const sendEvent = async (client: Client, roomId: string, html = false): Promise<ISendEventResponse> => {
53-
const content = {
53+
const content: IContent = {
5454
msgtype: "m.text" as MsgType,
5555
body: "Message",
56-
format: undefined,
57-
formatted_body: undefined,
5856
};
5957
if (html) {
6058
content.format = "org.matrix.custom.html";

0 commit comments

Comments
 (0)