question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remove private properties/methods from publicApi interfaces

See original GitHub issue

🐞 bug report

Affected Package

All @angular packages are affected

Is this a regression?

I am not sure, possibly at some point.

Description

If an angular class has any private properites/methods we cannot use it, but this will prevent us creating mock of that class for testing.

🔬 Minimal Reproduction

export declare class QueryList<T> {
    readonly dirty = true; // <-- Also an error, this should be boolean
    private _results;
    readonly changes: Observable<any>;
    readonly length: number;
    readonly first: T;
    readonly last: T;
    // ...
}

export QueryListMock<T> implements QueryList<T> {
    readonly dirty = true as true;
    private _results;
    readonly changes: Observable<any>;
    readonly length: number;
    readonly first: T;
    readonly last: T;
    // ...
}

As this is typescript relate issue I have typescript playground: here

🔥 Exception or Error


Class 'QueryListMock<T>' incorrectly implements class 'QueryList<T>'. Did you mean to extend 'QueryList<T>' and inherit its members as a subclass?
  Types have separate declarations of a private property '_results'.

🌍 Your Environment

Angular Version:


Angular CLI: 7.1.2
Node: 9.11.1
OS: win32 x64
Angular: 7.2.4
... animations, common, compiler, compiler-cli, core, forms
... language-service, platform-browser, platform-browser-dynamic
... router

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.2
@angular-devkit/build-angular     0.11.2
@angular-devkit/build-optimizer   0.11.2
@angular-devkit/build-webpack     0.11.2
@angular-devkit/core              7.1.2
@angular-devkit/schematics        7.1.2
@angular/cli                      7.1.2
@ngtools/webpack                  7.1.2
@schematics/angular               7.1.2
@schematics/update                0.11.2
rxjs                              6.4.0
typescript                        3.2.4
webpack                           4.23.1

Anything else relevant? This is due to https://github.com/Microsoft/TypeScript/issues/18499, as it seems, they wont resolve that anytime soon.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
pkozlowski-opensourcecommented, Mar 23, 2019

TypeScript aside we should be really exposing QueryList as an interface to users (without any private properties). Today we leak implementation details of the QueryList to our users 😦

0reactions
Akxecommented, Mar 23, 2019

@dawidgarus that is a very good point, TS should solve this not Angular I guess. Then there is that think that QueryList has property dirty with type true, not boolean… It propably should be fixed

Read more comments on GitHub >

github_iconTop Results From Across the Web

Explain why private and protected members in a class affect ...
Akxe mentioned this issue on Mar 22, 2019. Remove private properties/methods from publicApi interfaces angular/angular#29469.
Read more >
Mapped types: remove private interface - Stack Overflow
In TypeScript, private attributes are considered part of the shape (or interface) of a type. class Person { constructor(private name: string ...
Read more >
Provide package-private visibility modifier (or another scope ...
My use case is: a public API class with some internal members. Using internal is public in Java, so my internals leak into...
Read more >
PublicAPI (PegaRULES Java Engine v7.4.0 - Pega Community
The PublicAPI interface identifies the basic functionality available to all Java generated from ... This method WILL BE REMOVED in a future release....
Read more >
Restrictions on non-SDK interfaces - Android Developers
If you cannot find an alternative to using a non-SDK interface for a feature in your app, you should request a new public...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found