Skip to content
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

Type information is missing for private overloaded methods in .d.ts file #1532

Closed
cschleiden opened this issue Dec 18, 2014 · 2 comments
Closed
Labels
By Design Deprecated - use "Working as Intended" or "Design Limitation" instead

Comments

@cschleiden
Copy link

When this code:

class Test {
        private test(a: string);
        private test(a: number);
        private test(a: any) {
                console.log(a);
        }

        public test2(a: string);
        public test2(a: number);
        public test2(a: any) {
                console.log(a);
        }
}

new Test();

is compiled with the --declaration flag the output is:

declare class Test {
    private test(a);
    private test(a);
    test2(a: string): any;
    test2(a: number): any;
}

the type information is missing from test.

@ahejlsberg
Copy link
Member

That is by design. Private members are emitted in a declaration file to indicate that a private property with that name exists so that a derived class doesn't accidentally use the name (which would step on the private members). Since derived classes can't actually access inherited private members there is no reason to reveal their real types. Indeed, the private members may have non-exported types so it might not even be possible to include their real types.

@cschleiden
Copy link
Author

Ah okay, that makes sense. The two identical occurrences of test irritated me. Thanks for clarifying.

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

3 participants