Skip to content

Private members being emitted to definition file #2463

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
mtraynham opened this issue Mar 23, 2015 · 3 comments
Closed

Private members being emitted to definition file #2463

mtraynham opened this issue Mar 23, 2015 · 3 comments
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead

Comments

@mtraynham
Copy link

If they are supposed to be emitted, they are un-typed.

Seen in 1.4.1 and master.

Example:

Test.ts:

class Test {
    private static BAR: string = 'BAR';
    private _foo: string = 'foo';
}
export = Test;

tsc -d --target ES5 --module commonjs Test.ts

Test.d.ts:

declare class Test {
    private static BAR;
    private _foo;
}
export = Test;
@mtraynham
Copy link
Author

This was found when overloading a superclasses' setter/getter.

Throws error:
Class 'SubClass' incorrectly extends base class 'SuperClass'. Types have separate declarations of a private property '_foo'.

Parent project:

class ObjectA {
    public value: any;
}
class SuperClass {
    private _foo: ObjectA;
    public get foo(): ObjectA {
         return _foo;
    }
}

Parent defintiion:

declare class ObjectA {
    private value: any;
}
declare class SuperClass {
    private _foo;
    public foo: ObjectA;
}

Child project:

class ObjectB extends ObjectA {
    public value2: any;
}
class SubClass {
    private _foo: ObjectB;
    public get foo(): ObjectB {
         return _foo;
    }
}

@ahejlsberg
Copy link
Member

This is by design, see #1532.

@ahejlsberg ahejlsberg added the By Design Deprecated - use "Working as Intended" or "Design Limitation" instead label Mar 23, 2015
@mtraynham
Copy link
Author

Interesting. Thanks for the link. I couldn't seem to find an issue that related.

@microsoft microsoft locked and limited conversation to collaborators Jun 18, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead
Projects
None yet
Development

No branches or pull requests

2 participants