fix: align promise helper types and test playback rejections

This commit is contained in:
Harvey Zhao committed 2026-09-10 17:03:07 +08:00
1 parent 0f47e11d63
commit 72cf3551e2
13 files changed
+191 -44

No files matched your search

+10
View File
@@ -0,0 +1,10 @@
import type { Utils } from '../packages/artplayer/types/utils'
export function checkSilencePromiseTypes(utils: Utils, thenable: PromiseLike<number>) {
const promise: Promise<number | undefined> = utils.silencePromise(Promise.resolve(42))
const synchronous: undefined = utils.silencePromise(undefined)
const unchanged: PromiseLike<number> = utils.silencePromise(thenable)
// @ts-expect-error A catch-less thenable is not converted to a native Promise.
utils.silencePromise(thenable).catch(() => {})
return { promise, synchronous, unchanged }
}