Allow function and method type definitions to omit parameter names (make TS7051 configurable) #46583
Closed
5 tasks done
Labels
Duplicate
An existing issue was already created
Suggestion
π Search Terms
TS7051, nameless parameters
β Viability Checklist
My suggestion meets these guidelines:
β Suggestion
The following type definitions should be legal
Because
So parameter names should be treated just as documentation, and like all documentation, it should be optional (forcing documentation where it doesn't fit / isn't needed can add noise!).
π Motivating Example
Consider the very simple case
type BinaryOperator = (int, int) => int
.It's clearer on its own and any names for the parameters (
operand1, operand2
ora, b
orx, y
, orleft, right
) would clearly be redundant or feel forced.One real-life example is present at https://stackoverflow.com/q/42322251/1412255
π» Use Cases
What do you want to use this for?
I want to use this while designing interfaces.
What shortcomings exist with current approaches?
Forcing unnecessary name adds clutter to the process, or using sensible defaults (e.g. parameter named after the type, e.g.
a : A
) add refactoring / redesigning burden due to increased, manually managed, verbosity.What workarounds are you using in the meantime?
Giving random, sensible names. It's not that big of a deal, but it's more of a nice-to-have feature rather than if-this-doesnt-get-fixed-all-hell-will-break-lose kind of a feature.
The text was updated successfully, but these errors were encountered: