-
Notifications
You must be signed in to change notification settings - Fork 12.6k
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
Private variables in definition files #1867
Comments
Can you clarify? When the compiler generates a .d.ts for a class, it doesn't put type annotations on private members, so this shouldn't be a problem. |
Indeed, I had not noticed that they were not typed. |
A year later: privates are still generated in d.ts. Why are they there ? what is their added values ? |
It's absolutely necessary to have privates in generated .d.ts files. Otherwise you could derive from that class, declare a private of your own with the same name, and unknowingly stomp on your base class's private variable value. That failure mode would be very, very difficult to debug. |
When I produced definition files (.d.ts) for my projects, private variables of classes are also present.
Most of the time, I use internal libraries that require others definition files (jquery.d.ts for example), or definition files that are not present in lib.d.ts (Promises.d.ts and TouchEvent.d.ts for example).
But as I use private variables in my classes for wich the type is only defined in these definition files, my project generated definition file contains these types.
So without publish all the other .d.ts files with my project one, it is unusable.
Is there a way to manage it ? Or just remove the private variables to prevent these cases ?
Thanks
The text was updated successfully, but these errors were encountered: