Use function type shorthands when displaying signature help
See original GitHub issueIssue Analytics
- State:
- Created 7 years ago
- Comments:11 (9 by maintainers)
Top Results From Across the Web
How To Read Function Type Signatures - YouTube
For functional programming beginners: How to read type signatures. Also known as: What do all those silly characters mean?Being able to read ...
Read more >typing — Support for type hints — Python 3.11.1 documentation
Using that shorthand is recommended. Details: The arguments must be types and there must be at least one.
Read more >How types work with functions · F# for Fun and Profit - swlaschin
We've seen that the arrow notation " -> " is used to show the domain and range. So that a function signature always...
Read more >Viewing method parameter information | WebStorm ... - JetBrains
To have a complete method or function signature shown instead of a list of required types, select the Show full method signatures checkbox...
Read more >Use a screen reader to add a signature in Outlook
Type a name for the signature. When you're done, press Enter. Tip: Give signatures descriptive names, such as "business closing." A good name...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Sure thing @unional. All objects have a set of members. These aren’t the same things as properties. A property is a type of member, but members also include:
The thing that allows a type to be callable is a call signature. You might already be familiar with call signatures if you’ve thought about overloads.
Here is an example of a type with a single call signature:
If I have something of type
Foo
, I can call it with astring
andnumber
.You can also have multiple call signatures.
If
Foo
was declared like that, you could have also calledf
like so:We have two different shorter ways of writing things with call signatures. One place is method members.
If you have something like
Here,
Bar
is actually equivalent toMeaning that
Bar
has a property namedm
, which has a single call signature.Another short-hand that we use is arrow function types. These are just objects with a single call signature.
In other words, if you’ve ever seen
(x: number) => void
, that’s actually just an easier way of writing the type{ (x: number): void }
.Which is why I think that if you have an interface type with no members apart from a single call signature, we should consider showing the arrow function notation.
For more about call signatures, you can check out the language spec too: https://github.com/Microsoft/TypeScript/blob/master/doc/spec.md#3.9.2
@DanielRosenwasser many thanks! Great examples. Especially that
Bar
and the arrow function one. Didn’t know function signature is expanded to a property with single call signature (in this case). It does make a lot of sense.