From 90e2cbff151b57a94b3fa44ff1d68bc2e0f2658c Mon Sep 17 00:00:00 2001 From: AK <144495202+AKnassa@users.noreply.github.com> Date: Tue, 28 Apr 2026 00:57:53 -0400 Subject: [PATCH] chore(fullscreen): drop ts-expect-error, type ctx + NewState properly useServices is already typed via src/services/ServicesContext/useServices.d.ts, so the @ts-expect-error suppression on the import was unnecessary and masked two real type holes that surfaced once it was removed: - core.transport.getState('ctx') returns Promise; cast to the ambient Ctx type so escExitFullscreen is read through a typed path. - CoreTransport.on/off types listeners as () => void, but the 'NewState' event actually emits a string[]. Use a (...args: unknown[]) wrapper + Array.isArray narrowing so the call site stays type-safe without weakening the ambient transport signature. No behavior change. Made-with: Cursor --- src/common/Fullscreen/FullscreenProvider.tsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/common/Fullscreen/FullscreenProvider.tsx b/src/common/Fullscreen/FullscreenProvider.tsx index bbac4ab82..938df0b29 100644 --- a/src/common/Fullscreen/FullscreenProvider.tsx +++ b/src/common/Fullscreen/FullscreenProvider.tsx @@ -1,7 +1,6 @@ // Copyright (C) 2017-2023 Smart code 203358507 import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; -// @ts-expect-error JS module without types import { useServices } from 'stremio/services'; import useShell, { type WindowVisibility } from '../useShell'; import FullscreenContext, { type FullscreenContextValue } from './FullscreenContext'; @@ -63,7 +62,7 @@ const FullscreenProvider = ({ children }: Props) => { let cancelled = false; const refreshSettings = async () => { try { - const ctx = await core.transport.getState('ctx'); + const ctx = await core.transport.getState('ctx') as Ctx | null; if (!cancelled) { escExitFullscreenRef.current = !!ctx?.profile?.settings?.escExitFullscreen; } @@ -72,7 +71,11 @@ const FullscreenProvider = ({ children }: Props) => { } }; - const onNewState = (models: string[]) => { + // CoreTransport.on types the listener as () => void, but the 'NewState' + // event actually emits a string[] of changed model names. Read it via + // a rest-args wrapper to stay compatible with the ambient signature. + const onNewState = (...args: unknown[]) => { + const models = args[0]; if (Array.isArray(models) && models.indexOf('ctx') !== -1) { refreshSettings(); }