From 47bfec4e4694c6ea6ee83d01c9ec394ba2facc10 Mon Sep 17 00:00:00 2001 From: danranVm Date: Wed, 18 Mar 2020 15:28:25 +0800 Subject: [PATCH] feat(core): add `isPromise` generic (#34168) This commit adds generic to `isPromise` function to help with type inference. PR Close #34168 --- packages/common/upgrade/src/utils.ts | 2 +- packages/compiler/src/util.ts | 2 +- packages/core/src/util/lang.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/common/upgrade/src/utils.ts b/packages/common/upgrade/src/utils.ts index 97fcc594c1..48cba8e2fe 100644 --- a/packages/common/upgrade/src/utils.ts +++ b/packages/common/upgrade/src/utils.ts @@ -31,7 +31,7 @@ export function isAnchor(el: (Node & ParentNode) | Element | null): el is HTMLAn return (el).href !== undefined; } -export function isPromise(obj: any): obj is Promise { +export function isPromise(obj: any): obj is Promise { // allow any Promise/A+ compliant thenable. // It's up to the caller to ensure that obj.then conforms to the spec return !!obj && typeof obj.then === 'function'; diff --git a/packages/compiler/src/util.ts b/packages/compiler/src/util.ts index 01819f7225..789219e115 100644 --- a/packages/compiler/src/util.ts +++ b/packages/compiler/src/util.ts @@ -214,7 +214,7 @@ export function resolveForwardRef(type: any): any { /** * Determine if the argument is shaped like a Promise */ -export function isPromise(obj: any): obj is Promise { +export function isPromise(obj: any): obj is Promise { // allow any Promise/A+ compliant thenable. // It's up to the caller to ensure that obj.then conforms to the spec return !!obj && typeof obj.then === 'function'; diff --git a/packages/core/src/util/lang.ts b/packages/core/src/util/lang.ts index b6631e84d0..d69c39a146 100644 --- a/packages/core/src/util/lang.ts +++ b/packages/core/src/util/lang.ts @@ -11,7 +11,7 @@ import {Observable} from 'rxjs'; /** * Determine if the argument is shaped like a Promise */ -export function isPromise(obj: any): obj is Promise { +export function isPromise(obj: any): obj is Promise { // allow any Promise/A+ compliant thenable. // It's up to the caller to ensure that obj.then conforms to the spec return !!obj && typeof obj.then === 'function';