diff --git a/package.json b/package.json index aa3f88f2b5..d19d36bc0c 100644 --- a/package.json +++ b/package.json @@ -185,7 +185,7 @@ "stylelint": "^13.9.0", "stylelint-config-standard": "^20.0.0", "stylelint-scss": "^3.18.0", - "typescript": "4.3.5", + "typescript": "4.5.3", "walk": "^2.3.14" }, "resolutions": { diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts index ed14483fb6..e22dd89d13 100644 --- a/src/@types/global.d.ts +++ b/src/@types/global.d.ts @@ -66,6 +66,16 @@ declare global { // Needed for Safari, unknown to TypeScript webkitAudioContext: typeof AudioContext; + // https://docs.microsoft.com/en-us/previous-versions/hh772328(v=vs.85) + // we only ever check for its existence, so we can ignore its actual type + MSStream?: unknown; + + // https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1029#issuecomment-869224737 + // https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas + OffscreenCanvas?: { + new(width: number, height: number): OffscreenCanvas; + }; + mxContentMessages: ContentMessages; mxToastStore: ToastStore; mxDeviceListener: DeviceListener; @@ -123,11 +133,6 @@ declare global { } interface Document { - // https://developer.mozilla.org/en-US/docs/Web/API/Document/hasStorageAccess - hasStorageAccess?: () => Promise; - // https://developer.mozilla.org/en-US/docs/Web/API/Document/requestStorageAccess - requestStorageAccess?: () => Promise; - // Safari & IE11 only have this prefixed: we used prefixed versions // previously so let's continue to support them for now webkitExitFullscreen(): Promise; @@ -138,27 +143,26 @@ declare global { interface Navigator { userLanguage?: string; - // https://github.com/Microsoft/TypeScript/issues/19473 - // https://developer.mozilla.org/en-US/docs/Web/API/MediaSession - mediaSession: any; } interface StorageEstimate { usageDetails?: { [key: string]: number }; } - interface HTMLAudioElement { - type?: string; - // sinkId & setSinkId are experimental and typescript doesn't know about them - sinkId: string; - setSinkId(outputId: string); + // https://developer.mozilla.org/en-US/docs/Web/API/OffscreenCanvas + interface OffscreenCanvas { + height: number; + width: number; + getContext: HTMLCanvasElement["getContext"]; + convertToBlob(opts?: { + type?: string; + quality?: number; + }): Promise; + transferToImageBitmap(): ImageBitmap; } - interface HTMLVideoElement { + interface HTMLAudioElement { type?: string; - // sinkId & setSinkId are experimental and typescript doesn't know about them - sinkId: string; - setSinkId(outputId: string); } interface HTMLStyleElement { @@ -210,6 +214,11 @@ declare global { new (options?: AudioWorkletNodeOptions): AudioWorkletProcessor; }; + // https://github.com/microsoft/TypeScript-DOM-lib-generator/issues/1029#issuecomment-881509595 + interface AudioParamDescriptor { + readonly port: MessagePort; + } + // https://github.com/microsoft/TypeScript/issues/28308#issuecomment-650802278 function registerProcessor( name: string, diff --git a/src/ContentMessages.tsx b/src/ContentMessages.tsx index 02cc987735..1405362c83 100644 --- a/src/ContentMessages.tsx +++ b/src/ContentMessages.tsx @@ -131,8 +131,8 @@ async function createThumbnail( canvas = new window.OffscreenCanvas(targetWidth, targetHeight); } else { canvas = document.createElement("canvas"); - canvas.width = targetWidth; - canvas.height = targetHeight; + (canvas as HTMLCanvasElement).width = targetWidth; + (canvas as HTMLCanvasElement).height = targetHeight; } const context = canvas.getContext("2d"); diff --git a/yarn.lock b/yarn.lock index 959cf70c79..515d0b4e3a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8440,10 +8440,10 @@ typedarray-to-buffer@^3.1.5: dependencies: is-typedarray "^1.0.0" -typescript@4.3.5: - version "4.3.5" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.3.5.tgz#4d1c37cc16e893973c45a06886b7113234f119f4" - integrity sha512-DqQgihaQ9cUrskJo9kIyW/+g0Vxsk8cDtZ52a3NGh0YNTfpUSArXSohyUGnvbPazEPLu398C0UxmKSOrPumUzA== +typescript@4.5.3: + version "4.5.3" + resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.5.3.tgz#afaa858e68c7103317d89eb90c5d8906268d353c" + integrity sha512-eVYaEHALSt+s9LbvgEv4Ef+Tdq7hBiIZgii12xXJnukryt3pMgJf6aKhoCZ3FWQsu6sydEnkg11fYXLzhLBjeQ== ua-parser-js@^0.7.30: version "0.7.31"