Skip to content

Private properties defined in an external npm package interrupt variable assignment #2092

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

Closed
jeffwhelpley opened this issue Oct 28, 2016 · 4 comments

Comments

@jeffwhelpley
Copy link

RxJS version: 5.0.0-beta.12

Code to reproduce:

// in one npm module A
export class HttpAdapter {
    request(url: string, options?: HttpRequestOptionsArgs): Observable<HttpResponse> {
        return Observable.of({});
    }
}

// in completely separate npm module B that references module A
// issue occurs when you do npm link from module B to A 
export class HttpRequestAdapter implements HttpAdapter {
    request(url: string, options?: HttpRequestOptionsArgs): Observable<HttpResponse> {
        return Observable.of({});
    }
}

Expected behavior: No Errors

Actual behavior:

Error:(10, 14) TS2420:Class 'HttpRequestAdapter' incorrectly implements interface 'HttpAdapter'.
  Types of property 'request' are incompatible.
    Type '(url: string, options?: HttpRequestOptionsArgs) => Observable<HttpResponse>' is not assignable to type '(url: string, options?: HttpRequestOptionsArgs) => Observable<HttpResponse>'.
      Type 'Observable<HttpResponse>' is not assignable to type 'Observable<HttpResponse>'.
        Property 'source' is protected but type 'Observable<T>' is not a class derived from 'Observable<T>'.

Additional information:

According to this open TypeScript issue this problem appears because of private variables within the Observable type. Technically this should be a bug that is fixed within TypeScript, but it would be extremely helpful if in the meantime we could make the Observable properties public so that npm linking works as expected. It seems like this is something that may not be resolved in the TypeScript lib for some time.

@kwonoj
Copy link
Member

kwonoj commented Oct 28, 2016

Is this same issue to #1744 and #1858 ?

@benlesh
Copy link
Member

benlesh commented Oct 28, 2016

Technically this should be a bug that is fixed within TypeScript, but it would be extremely helpful if in the meantime we could make the Observable properties public so that npm linking works as expected.

I feel like there will be other problems if we make properties that should be private public.

@jeffwhelpley
Copy link
Author

@Blesh yeah, no worries if you feel that is going to adversely affect the project. I will just close this and focus on seeing how to get it resolved in TypeScript core. I just opened in case you didn't care one way or another about the private/public designation.

@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

3 participants