1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

Iterate typing to work towards noImplicitAny (#2061)

This commit is contained in:
Michael Telatynski
2021-12-14 14:32:35 +00:00
committed by GitHub
parent aeec4aa4a8
commit 963c7690b6
16 changed files with 161 additions and 140 deletions

View File

@@ -621,7 +621,7 @@ export interface IMyDevice {
last_seen_ts?: number;
}
interface IDownloadKeyResult {
export interface IDownloadKeyResult {
failures: { [serverName: string]: object };
device_keys: {
[userId: string]: {
@@ -632,13 +632,42 @@ interface IDownloadKeyResult {
};
};
};
// the following three fields were added in 1.1
master_keys?: {
[userId: string]: {
keys: { [keyId: string]: string };
usage: string[];
user_id: string;
};
};
self_signing_keys?: {
[userId: string]: {
keys: { [keyId: string]: string };
signatures: ISignatures;
usage: string[];
user_id: string;
};
};
user_signing_keys?: {
[userId: string]: {
keys: { [keyId: string]: string };
signatures: ISignatures;
usage: string[];
user_id: string;
};
};
}
interface IClaimOTKsResult {
export interface IClaimOTKsResult {
failures: { [serverName: string]: object };
one_time_keys: {
[userId: string]: {
[deviceId: string]: string;
[deviceId: string]: {
[keyId: string]: {
key: string;
signatures: ISignatures;
};
};
};
};
}
@@ -1421,14 +1450,12 @@ export class MatrixClient extends EventEmitter {
}
}
// We swallow errors because we need a default object anyhow
return this.http.authedRequest(
undefined, "GET", "/capabilities",
).catch((e: Error) => {
).catch((e: Error): void => {
// We swallow errors because we need a default object anyhow
logger.error(e);
return null; // otherwise consume the error
}).then((r) => {
if (!r) r = {};
}).then((r: { capabilities?: ICapabilities } = {}) => {
const capabilities: ICapabilities = r["capabilities"] || {};
// If the capabilities missed the cache, cache it for a shorter amount
@@ -2836,7 +2863,7 @@ export class MatrixClient extends EventEmitter {
}
let totalKeyCount = 0;
let keys = [];
let keys: IMegolmSessionData[] = [];
const path = this.makeKeyBackupPath(targetRoomId, targetSessionId, backupInfo.version);
@@ -5692,18 +5719,14 @@ export class MatrixClient extends EventEmitter {
searchResults.count = roomEvents.count;
searchResults.next_batch = roomEvents.next_batch;
// combine the highlight list with our existing list; build an object
// to avoid O(N^2) fail
const highlights = {};
roomEvents.highlights.forEach((hl) => {
highlights[hl] = 1;
});
// combine the highlight list with our existing list;
const highlights = new Set<string>(roomEvents.highlights);
searchResults.highlights.forEach((hl) => {
highlights[hl] = 1;
highlights.add(hl);
});
// turn it back into a list.
searchResults.highlights = Object.keys(highlights);
searchResults.highlights = Array.from(highlights);
// append the new results to our existing results
const resultsLength = roomEvents.results ? roomEvents.results.length : 0;
@@ -5794,11 +5817,9 @@ export class MatrixClient extends EventEmitter {
return this.http.authedRequest(
undefined, "GET", path, undefined, undefined,
).then((response) => {
).then((response: IFilterDefinition) => {
// persist the filter
const filter = Filter.fromJson(
userId, filterId, response,
);
const filter = Filter.fromJson(userId, filterId, response);
this.store.storeFilter(filter);
return filter;
});
@@ -6096,7 +6117,7 @@ export class MatrixClient extends EventEmitter {
{
prefix: '',
},
).catch((e) => {
).catch((e: Error) => {
// Need to unset this if it fails, otherwise we'll never retry
this.serverVersionsPromise = null;
// but rethrow the exception to anything that was waiting
@@ -6420,7 +6441,7 @@ export class MatrixClient extends EventEmitter {
public isUsernameAvailable(username: string): Promise<true> {
return this.http.authedRequest(
undefined, "GET", '/register/available', { username: username },
).then((response) => {
).then((response: { available: boolean }) => {
return response.available;
});
}
@@ -7741,11 +7762,11 @@ export class MatrixClient extends EventEmitter {
* an error response ({@link module:http-api.MatrixError}).
*/
public claimOneTimeKeys(
devices: string[],
devices: [string, string][],
keyAlgorithm = "signed_curve25519",
timeout?: number,
): Promise<IClaimOTKsResult> {
const queries = {};
const queries: Record<string, Record<string, string>> = {};
if (keyAlgorithm === undefined) {
keyAlgorithm = "signed_curve25519";