Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): add isPromise generic #34168

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/common/upgrade/src/utils.ts
Expand Up @@ -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';
danranVm marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/util.ts
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/util/lang.ts
Expand Up @@ -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';
Expand Down