From ce097d50423546403b0a19bd5f9acfcf0dc04454 Mon Sep 17 00:00:00 2001 From: Paul Berberian Date: Thu, 1 Aug 2024 14:21:36 +0200 Subject: [PATCH] Rewrite type check compatibility trick after review --- src/compat/browser_compatibility_types.ts | 64 +++++------------------ 1 file changed, 13 insertions(+), 51 deletions(-) diff --git a/src/compat/browser_compatibility_types.ts b/src/compat/browser_compatibility_types.ts index 54a149c103..30b2701123 100644 --- a/src/compat/browser_compatibility_types.ts +++ b/src/compat/browser_compatibility_types.ts @@ -317,57 +317,19 @@ export interface IMediaKeySession extends IEventTarget update(response: BufferSource): Promise; } -/* eslint-disable @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types */ -// @ts-expect-error unused function, just used for compile-time typechecking -function testMediaElement(x: HTMLMediaElement) { - assertCompatibleIMediaElement(x); -} -function assertCompatibleIMediaElement(_x: IMediaElement) { - // Noop -} -// @ts-expect-error unused function, just used for compile-time typechecking -function testMediaSource(x: MediaSource) { - assertCompatibleIMediaSource(x); -} -function assertCompatibleIMediaSource(_x: IMediaSource) { - // Noop -} -// @ts-expect-error unused function, just used for compile-time typechecking -function testSourceBuffer(x: SourceBuffer) { - assertCompatibleISourceBuffer(x); -} -function assertCompatibleISourceBuffer(_x: ISourceBuffer) { - // Noop -} -// @ts-expect-error unused function, just used for compile-time typechecking -function testSourceBufferList(x: SourceBufferList) { - assertCompatibleISourceBufferList(x); -} -function assertCompatibleISourceBufferList(_x: ISourceBufferList) { - // Noop -} -// @ts-expect-error unused function, just used for compile-time typechecking -function testMediaKeySystemAccess(x: MediaKeySystemAccess) { - assertCompatibleIMediaKeySystemAccess(x); -} -function assertCompatibleIMediaKeySystemAccess(_x: IMediaKeySystemAccess) { - // Noop -} -// @ts-expect-error unused function, just used for compile-time typechecking -function testMediaKeys(x: MediaKeys) { - assertCompatibleIMediaKeys(x); -} -function assertCompatibleIMediaKeys(_x: IMediaKeys) { - // Noop -} -// @ts-expect-error unused function, just used for compile-time typechecking -function testMediaKeySession(x: MediaKeySession) { - assertCompatibleIMediaKeySession(x); -} -function assertCompatibleIMediaKeySession(_x: IMediaKeySession) { - // Noop -} -/* eslint-enable @typescript-eslint/no-unused-vars, @typescript-eslint/ban-types */ +/* eslint-disable @typescript-eslint/ban-types */ +// Trick to ensure our own types are compatible to TypeScript's +function assertTypeCompatibility(): void { + // noop +} +assertTypeCompatibility(); +assertTypeCompatibility(); +assertTypeCompatibility(); +assertTypeCompatibility(); +assertTypeCompatibility(); +assertTypeCompatibility(); +assertTypeCompatibility(); +/* eslint-enable @typescript-eslint/ban-types */ /** * AudioTrackList implementation (that TS forgot).