Support declaring multiple setter overloads #60664
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
setter overload, multiple setter signatures, multiple setter input types
β Viability Checklist
β Suggestion
TypeScript allows declaring multiple different argument signatures for a function, i.e. "function overloads": https://www.typescriptlang.org/docs/handbook/2/functions.html#function-overloads.
We should be able to do the same for property setters, since they are modeled much like a function taking a single argument.
π Motivating Example
A setter might want to separate different types of inputs for improved clarity of documentation:
Note that these differ not just in documentation but also in the value argument's name, which often appears in generated docs output too.
π» Use Cases
Although setter overloads are necessarily less versatile than function overloads with multiple parameters, some of the same rationales for the overload feature still apply to setters β as seen in the example above.
Workaround
As with functions before overloading is supported, the workaround is just to glom all the docs together with some additional verbiage, e.g.:
The text was updated successfully, but these errors were encountered: