-
Notifications
You must be signed in to change notification settings - Fork 51
fix: correct privacy and type propagation #300
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
base: master
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for custom-elements-manifest-analyzer ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
Hi @thepassle, We have UI library that internally uses |
@nnaydenow this one is kind of a unique use case and seems very problematic. I believe the changes you proposed would break the privacy inheritance for properties using the TypeScript access modifiers ( Is there a reason you're not able to use one of the standard access modifier techniques instead of using JSDoc tags? |
Hi @break-stuff, Yes, our component templates are in separate TSX files, and using standard access modifiers causes TypeScript to complain about inaccessible properties. You're also right that exposing a private property from a parent class in a child class can be problematic, as TypeScript’s inheritance chain doesn’t always account for what might come from the parent. However, my example may not have been the best illustration. In our project, "private" and "protected" effectively mean the same thing: they indicate internal usage. These properties are not supported outside our organization and should not be used by developers consuming the library. In most cases, they are intended to be protected. A common pattern in our project is using a base class for code reuse. For example, we have a That said, I’m curious—why is it that a child class can override everything except type and privacy? Could you share your thoughts on this? Why does this need to be enforced by the analyzer rather than being left to the consumer of the analyzer? Update: For me the provided example a valid use case |
In a child class, you can override both the visibility and type of a property from the parent class. For example, you can change a private property in the parent class to be public in the child class. Additionally, you can refine the type to a subset of the original type.
Updated example is added in: #300 (comment)