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

Compiler error: AsyncSubject returns Observable, should return AsyncSubject. #2982

Closed
raysuelzer opened this issue Oct 19, 2017 · 3 comments
Closed

Comments

@raysuelzer
Copy link

raysuelzer commented Oct 19, 2017

RxJS version:
5.5.0

Code to reproduce:

 import {AsyncSubject} from 'rxjs/Rx';
export class ShouldWork {
    subject: AsyncSubject<boolean> = new AsyncSubject<boolean>().map(t => t);
}

Expected behavior:
Should not throw typescript error. Should know that return type is a subject not observable.
Actual behavior:
severity: 'Error'
message: 'Type 'Observable' is not assignable to type 'AsyncSubject'.
Property 'value' is missing in type 'Observable'.'
Additional information:
Occurs on Typescript versions: 2.4.0, 2.4.1, 2.5.3
Occurs even with --noStrictGenericChecks

@kwonoj
Copy link
Member

kwonoj commented Oct 19, 2017

It is currently known expected design of extended variant of observable doesn't carry over its characteristics via operator chain by creating new observables. Similar, or possible dupe of #2378.

@kwonoj kwonoj closed this as completed Oct 19, 2017
@raysuelzer
Copy link
Author

This only seems partially true to me, as all of the characteristics from my return object are carried over via operator chain except for .value. I know there is a reason for this, but it is a big bummer that you can't use typescript with AsyncSubject because it thinks it is returning an Observable when it isn't.

image

@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

2 participants