Skip to content

Class expose private methods #20716

Closed
Closed
@sosoba

Description

@sosoba

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();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions