Suggestion: shorthand syntax for annotating function with type #16334
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
I like to define types for my functions by separating the type out from the value:
This helps particularly for longer functions where the parameter list often spans many columns and multiple lines.
However, compared to Elm/Haskell, this code is quite boilerplate-y. I wonder if there is some shorthand syntax we could add to make this pattern more concise. For example, the same code in Elm/Haskell:
The boilerplate in the current TypeScript syntax is:
id
) with type of same name (id
). Could this be automatic, e.g. matched by name?A => A
, omitting the parameter names? Or would this cause problems?The text was updated successfully, but these errors were encountered: