private fields in nested classes should have separate types? #60882
Labels
Awaiting More Feedback
This means we'd like to hear from more people who would be helped by this feature
Suggestion
An idea for TypeScript
π Search Terms
typescript private field nested class
β Viability Checklist
β Suggestion
Private fields of a wrapper class are similar to symbols: perhaps the nested classes could have their own types for the fields based on the value they initialize in their constructor:
π Motivating Example
https://www.typescriptlang.org/play/?noImplicitAny=false#code/MYGwhgzhAEBiBOBLApgOwCYwN4CgCQAxAG5ggCuyO+sA9jdALzSiQy33IAeALmpnEj7Z8eYDVQRu8MsG414ACgCU0XHnUQyAB2SKlIvNwAWiCADpipCo2gAWAKwA2aAHoX0ADwBaH779foVDIAWwAjXREAXyp1ADM6AFlkYxp0ZVUDMQkaEGQzEBoAcwVjUwsScmR9dWi8aPwAITB4GxYoaCaWrl4MGFLzdgz1LMlpWXl0tQ1tXWUDfvKrZBsAIgB2AA4AThXXd29-Q59oUcRUQqiYvFDmpJS0lSnRcQgcvILihctK6rr8aPqI24qnYABoOs1IjZUMgAO4CFC9OY4IHQWLQuFwOhzVGhDHwzrI2JmeI0O5GVLpNzQD4wFYORwrHChMw3eDkykqam06DrbYrIA
Plain JS:
π» Use Cases
Allows having a "private" key to use on multiple classes, but each class could have a different type of value.
The text was updated successfully, but these errors were encountered: