Typescript updates (#9658)
* Typescript updates * Update @types/node * Fix more types
This commit is contained in:
parent
baaa9f5dd2
commit
d258402186
59 changed files with 86 additions and 90 deletions
|
@ -241,7 +241,7 @@ export default class MultiInviter {
|
|||
break;
|
||||
case "M_LIMIT_EXCEEDED":
|
||||
// we're being throttled so wait a bit & try again
|
||||
setTimeout(() => {
|
||||
window.setTimeout(() => {
|
||||
this.doInvite(address, ignoreProfile).then(resolve, reject);
|
||||
}, 5000);
|
||||
return;
|
||||
|
|
|
@ -55,7 +55,7 @@ export default class Timer {
|
|||
this.setNotStarted();
|
||||
} else {
|
||||
const delta = this.timeout - elapsed;
|
||||
this.timerHandle = setTimeout(this.onTimeout, delta);
|
||||
this.timerHandle = window.setTimeout(this.onTimeout, delta);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -78,7 +78,7 @@ export default class Timer {
|
|||
start() {
|
||||
if (!this.isRunning()) {
|
||||
this.startTs = Date.now();
|
||||
this.timerHandle = setTimeout(this.onTimeout, this.timeout);
|
||||
this.timerHandle = window.setTimeout(this.onTimeout, this.timeout);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ export default class WidgetUtils {
|
|||
resolve();
|
||||
}
|
||||
}
|
||||
const timerId = setTimeout(() => {
|
||||
const timerId = window.setTimeout(() => {
|
||||
MatrixClientPeg.get().removeListener(ClientEvent.AccountData, onAccountData);
|
||||
reject(new Error("Timed out waiting for widget ID " + widgetId + " to appear"));
|
||||
}, WIDGET_WAIT_TIME);
|
||||
|
@ -221,7 +221,7 @@ export default class WidgetUtils {
|
|||
resolve();
|
||||
}
|
||||
}
|
||||
const timerId = setTimeout(() => {
|
||||
const timerId = window.setTimeout(() => {
|
||||
MatrixClientPeg.get().removeListener(RoomStateEvent.Events, onRoomStateEvents);
|
||||
reject(new Error("Timed out waiting for widget ID " + widgetId + " to appear"));
|
||||
}, WIDGET_WAIT_TIME);
|
||||
|
|
|
@ -27,7 +27,7 @@ function showToast(text) {
|
|||
const el = document.getElementById("snackbar");
|
||||
el.innerHTML = text;
|
||||
el.className = "mx_show";
|
||||
setTimeout(() => {
|
||||
window.setTimeout(() => {
|
||||
el.className = el.className.replace("mx_show", "");
|
||||
}, 2000);
|
||||
}
|
||||
|
|
|
@ -77,10 +77,10 @@ export async function createThumbnail(
|
|||
}
|
||||
|
||||
let canvas: HTMLCanvasElement | OffscreenCanvas;
|
||||
let context: CanvasRenderingContext2D;
|
||||
let context: CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D;
|
||||
try {
|
||||
canvas = new window.OffscreenCanvas(targetWidth, targetHeight);
|
||||
context = canvas.getContext("2d");
|
||||
context = canvas.getContext("2d") as OffscreenCanvasRenderingContext2D;
|
||||
} catch (e) {
|
||||
// Fallback support for other browsers (Safari and Firefox for now)
|
||||
canvas = document.createElement("canvas");
|
||||
|
@ -92,7 +92,7 @@ export async function createThumbnail(
|
|||
context.drawImage(element, 0, 0, targetWidth, targetHeight);
|
||||
|
||||
let thumbnailPromise: Promise<Blob>;
|
||||
if (window.OffscreenCanvas && canvas instanceof window.OffscreenCanvas) {
|
||||
if (window.OffscreenCanvas && canvas instanceof OffscreenCanvas) {
|
||||
thumbnailPromise = canvas.convertToBlob({ type: mimeType });
|
||||
} else {
|
||||
thumbnailPromise = new Promise<Blob>(resolve => (canvas as HTMLCanvasElement).toBlob(resolve, mimeType));
|
||||
|
|
|
@ -102,10 +102,10 @@ export async function waitForRoomReadyAndApplyAfterCreateCallbacks(
|
|||
finish();
|
||||
};
|
||||
|
||||
const checkRoomStateIntervalHandle = setInterval(() => {
|
||||
const checkRoomStateIntervalHandle = window.setInterval(() => {
|
||||
if (isRoomReady(client, localRoom)) finish();
|
||||
}, 500);
|
||||
const stopgapTimeoutHandle = setTimeout(stopgapFinish, 5000);
|
||||
const stopgapTimeoutHandle = window.setTimeout(stopgapFinish, 5000);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ export async function waitForMember(client: MatrixClient, roomId: string, userId
|
|||
|
||||
/* We don't want to hang if this goes wrong, so we proceed and hope the other
|
||||
user is already in the megolm session */
|
||||
setTimeout(resolve, timeout, false);
|
||||
window.setTimeout(resolve, timeout, false);
|
||||
}).finally(() => {
|
||||
client.removeListener(RoomStateEvent.NewMember, handler);
|
||||
});
|
||||
|
|
|
@ -18,7 +18,7 @@ limitations under the License.
|
|||
// or when the timeout of ms is reached with the value of given timeoutValue
|
||||
export async function timeout<T, Y>(promise: Promise<T>, timeoutValue: Y, ms: number): Promise<T | Y> {
|
||||
const timeoutPromise = new Promise<T | Y>((resolve) => {
|
||||
const timeoutId = setTimeout(resolve, ms, timeoutValue);
|
||||
const timeoutId = window.setTimeout(resolve, ms, timeoutValue);
|
||||
promise.then(() => {
|
||||
clearTimeout(timeoutId);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue