Skip to content

Class expose private methods #20716

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
sosoba opened this issue Dec 15, 2017 · 1 comment
Closed

Class expose private methods #20716

sosoba opened this issue Dec 15, 2017 · 1 comment
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug

Comments

@sosoba
Copy link

sosoba commented Dec 15, 2017

TypeScript Version: 2.7.0-dev.20171215

Code

class ServerService {

    public getData(){
        this.privateGetData() + 2;
    };

    private privateGetData(){
        return 2;
    };

}

abstract class Client implements ServerService {

    getData():void;

}

Expected behavior:
.d.ts

declare class ServerService {
    getData(): void;
}

Compile success

Actual behavior:
TS2420: Class 'Client' incorrectly implements interface 'ServerService'.
Property 'privateGetData' is missing in type 'Client'.

.d.ts

declare class ServerService {
    getData(): void;
    private privateGetData();
}
@RyanCavanaugh RyanCavanaugh added the Working as Intended The behavior described is the intended behavior; this is not a bug label Dec 15, 2017
@RyanCavanaugh
Copy link
Member

See e.g. #10516, or ask a question on Stack Overflow if you would like more explanation as to why this works the way it does

@microsoft microsoft locked and limited conversation to collaborators Jun 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Working as Intended The behavior described is the intended behavior; this is not a bug
Projects
None yet
Development

No branches or pull requests

2 participants