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

Use PromiseConstructorLike and PromiseLike for operators/toPromise #2904

Closed
cartant opened this issue Oct 5, 2017 · 1 comment
Closed

Use PromiseConstructorLike and PromiseLike for operators/toPromise #2904

cartant opened this issue Oct 5, 2017 · 1 comment

Comments

@cartant
Copy link
Collaborator

cartant commented Oct 5, 2017

The overload signatures for the new operators/toPromise function include:

export function toPromise<T>(PromiseCtor: typeof Promise): UnaryFunction<Observable<T>, Promise<T>>;

If the intention is to allow for the use of an arbitrary promise implementation, this seems overly specific.

PromiseConstructorLike and PromiseLike could be used instead:

export function toPromise<T>(PromiseCtor: PromiseConstructorLike): UnaryFunction<Observable<T>, PromiseLike<T>>;

RxJS version: 5.5.0-beta.3

Code to reproduce:

import { Promise as Bluebird } from "bluebird";
import { toPromise } from "rxjs/operators";

const func = toPromise(Bluebird);

Expected behavior:

No error.

Actual behavior:

An error is effected, as Bluebird does not include the Symbol.species property.

Additional information:

Since at least version 2.0.10, TypeScript's in-built typings have included PromiseLike and PromiseConstructorLike.

cartant added a commit to cartant/rxjs that referenced this issue Oct 5, 2017
Add an overload signature that uses PromiseConstructorLike and
PromiseLike.

Closes ReactiveX#2904
cartant added a commit to cartant/rxjs that referenced this issue Oct 5, 2017
Add an overload signature that uses PromiseConstructorLike and
PromiseLike.

Closes ReactiveX#2904
@benlesh benlesh closed this as completed in 124e231 Oct 5, 2017
@lock
Copy link

lock bot commented Jun 6, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant