]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Type isPromise
authorChocobozzz <me@florianbigard.com>
Tue, 24 Jan 2023 10:57:25 +0000 (11:57 +0100)
committerChocobozzz <me@florianbigard.com>
Tue, 24 Jan 2023 10:57:25 +0000 (11:57 +0100)
shared/core-utils/common/promises.ts

index dc0db9074825594d3298e0c48b376b6dd16acc4d..f17221b97fb61841f7aeeb86c1d2cd4f6b9b4341 100644 (file)
@@ -1,5 +1,5 @@
-function isPromise (value: any) {
-  return value && typeof value.then === 'function'
+function isPromise <T = unknown> (value: T | Promise<T>): value is Promise<T> {
+  return value && typeof (value as Promise<T>).then === 'function'
 }
 
 function isCatchable (value: any) {