From 54e8f3c9d0a1ef0daa5c518fc303c9abe0656a90 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Mon, 12 May 2025 10:02:49 +0100
Subject: [PATCH] Simplify global types (#4831)

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
 src/@types/global.d.ts     | 38 +++++++-------------------------------
 src/webrtc/mediaHandler.ts |  2 +-
 2 files changed, 8 insertions(+), 32 deletions(-)

diff --git a/src/@types/global.d.ts b/src/@types/global.d.ts
index c679e3cae..b89aefa99 100644
--- a/src/@types/global.d.ts
+++ b/src/@types/global.d.ts
@@ -14,9 +14,6 @@ See the License for the specific language governing permissions and
 limitations under the License.
 */
 
-// this is needed to tell TS about globalThis.Olm
-import "@matrix-org/olm";
-
 export {};
 
 declare global {
@@ -34,39 +31,18 @@ declare global {
         }
     }
 
-    interface MediaDevices {
-        // This is experimental and types don't know about it yet
-        // https://github.com/microsoft/TypeScript/issues/33232
-        getDisplayMedia(constraints: MediaStreamConstraints | DesktopCapturerConstraints): Promise<MediaStream>;
-        getUserMedia(constraints: MediaStreamConstraints | DesktopCapturerConstraints): Promise<MediaStream>;
-    }
-
-    interface DesktopCapturerConstraints {
-        audio:
-            | boolean
-            | {
-                  mandatory: {
-                      chromeMediaSource: string;
-                      chromeMediaSourceId: string;
-                  };
-              };
-        video:
-            | boolean
-            | {
-                  mandatory: {
-                      chromeMediaSource: string;
-                      chromeMediaSourceId: string;
-                  };
-              };
+    // Chrome-specific getUserMedia constraints
+    interface MediaTrackConstraints {
+        mandatory?: {
+            chromeMediaSource: string;
+            chromeMediaSourceId: string;
+        };
     }
 
-    // eslint-disable-next-line @typescript-eslint/no-empty-object-type
-    interface DummyInterfaceWeShouldntBeUsingThis {}
-
     interface Navigator {
         // We check for the webkit-prefixed getUserMedia to detect if we're
         // on webkit: we should check if we still need to do this
-        webkitGetUserMedia?: DummyInterfaceWeShouldntBeUsingThis;
+        webkitGetUserMedia?: unknown;
     }
 
     export interface Uint8ArrayToBase64Options {
diff --git a/src/webrtc/mediaHandler.ts b/src/webrtc/mediaHandler.ts
index ea70f7f64..dfdde3f6b 100644
--- a/src/webrtc/mediaHandler.ts
+++ b/src/webrtc/mediaHandler.ts
@@ -462,7 +462,7 @@ export class MediaHandler extends TypedEventEmitter<
         };
     }
 
-    private getScreenshareContraints(opts: IScreensharingOpts): DesktopCapturerConstraints {
+    private getScreenshareContraints(opts: IScreensharingOpts): MediaStreamConstraints {
         const { desktopCapturerSourceId, audio } = opts;
         if (desktopCapturerSourceId) {
             return {
-- 
GitLab