feat(core): add `isPromise` generic (#34168)
This commit adds generic to `isPromise` function to help with type inference. PR Close #34168
This commit is contained in:
parent
b4972fa165
commit
47bfec4e46
|
@ -31,7 +31,7 @@ export function isAnchor(el: (Node & ParentNode) | Element | null): el is HTMLAn
|
|||
return (<HTMLAnchorElement>el).href !== undefined;
|
||||
}
|
||||
|
||||
export function isPromise(obj: any): obj is Promise<any> {
|
||||
export function isPromise<T = any>(obj: any): obj is Promise<T> {
|
||||
// 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';
|
||||
|
|
|
@ -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<any> {
|
||||
export function isPromise<T = any>(obj: any): obj is Promise<T> {
|
||||
// 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';
|
||||
|
|
|
@ -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<any> {
|
||||
export function isPromise<T = any>(obj: any): obj is Promise<T> {
|
||||
// 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';
|
||||
|
|
Loading…
Reference in New Issue