-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Suggestion: use :{type}
to omit formal parameter when declare function interface or something else
#10984
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The formal parameter name is often useful for intellisense when using semantically meaningful parameter names, is it not? |
I mean, you can't stop someone from not providing a useful name. |
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 |
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. |
When we declare a function interface, omit formal parameter. Because the param name is not important in interface, just the param type does.
So, we can make below code
to this form
The text was updated successfully, but these errors were encountered: