Allow overload signatures to have different access levels #58316
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
error TS2385: Overload signatures must all be public, private or protected
β Viability Checklist
β Suggestion
What I would like to achieve with that is, that tsc checks, that I can only call public signatures from outside of a class, while I can also call private signatures from inside the class and protected ones from inside a child class.
Originally posted by @0815fox in #7577 (comment)
See also the full posts below:
#7577 (comment)
#58303
π Motivating Example
If I don't add an extra line
I get the error
"Argument of type 'G | Q | null | undefined' is not assignable to parameter of type 'G | null'."
But that function signature should not be ever called from the outside because the function body cannot tell if params is actually a query object if the second input is undefined, which is why I have the restriction on the second overlord. That is why I need protected for the third overload.
π» Use Cases
super.method.apply doesn't work because I get
Argument of type 'IArguments' is not assignable to parameter of type '[params: G | null, data: D]'
The text was updated successfully, but these errors were encountered: