You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 ?
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.
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.
A year later: privates are still generated in d.ts. Why are they there ? what is their added values ?
This forces my class to be treated as a nominal type instead of structural type.
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.
Activity
RyanCavanaugh commentedon Jan 30, 2015
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.
paztis commentedon Jan 31, 2015
Indeed, I had not noticed that they were not typed.
I must have some public variables referencing these types.
georgehdd commentedon Apr 12, 2016
A year later: privates are still generated in d.ts. Why are they there ? what is their added values ?
This forces my class to be treated as a nominal type instead of structural type.
RyanCavanaugh commentedon Apr 12, 2016
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.