You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Suggestion: use :{type} to omit formal parameter when declare function interface or something else #10984
I mean, TypeScript can support this form but it's optional. So someone can omit the formal parameter name. Because sometime we don't know the correct parameter name until we implement it
There are situations like this where omitting some parameter names would be a small mercy. But that particular pattern will hopefully one day be addressed better by something like #5453.
In general there are cases where the intent of declaring a function type is purely to describe a mapping from certain parameter type(s) to a certain return type, and giving names to the parameters is mostly meaningless boilerplate. You can see some of these in ramda.d.ts.
Basically any situation where you'd be temped to name things arg1, arg2 and so on would be candidates for this proposal. The compiler would probably internally name them arg1, arg2 etc for intellisense anyway.
We'd really like people to try hard to come up with parameter names, and this syntax looks really weird on its own (is it a weird kind of parameter name? a destructuring? something else?) so we'd prefer to keep names mandatory at this point.
Activity
kitsonk commentedon Sep 19, 2016
The formal parameter name is often useful for intellisense when using semantically meaningful parameter names, is it not?
RyanCavanaugh commentedon Sep 19, 2016
I mean, you can't stop someone from not providing a useful name.
p0, p1, p2, etc.ik0r commentedon Sep 20, 2016
I mean, TypeScript can support this form but it's optional. So someone can omit the formal parameter name. Because sometime we don't know the correct parameter name until we implement it
yortus commentedon Sep 20, 2016
There are situations like this where omitting some parameter names would be a small mercy. But that particular pattern will hopefully one day be addressed better by something like #5453.
In general there are cases where the intent of declaring a function type is purely to describe a mapping from certain parameter type(s) to a certain return type, and giving names to the parameters is mostly meaningless boilerplate. You can see some of these in ramda.d.ts.
Basically any situation where you'd be temped to name things
arg1,arg2and so on would be candidates for this proposal. The compiler would probably internally name themarg1,arg2etc for intellisense anyway.RyanCavanaugh commentedon Sep 28, 2016
We'd really like people to try hard to come up with parameter names, and this syntax looks really weird on its own (is it a weird kind of parameter name? a destructuring? something else?) so we'd prefer to keep names mandatory at this point.