Methods like getFirstChildOrThrow should have typeguard overloads
See original GitHub issueThis should be possible to infer automatically, since isBlock
is a type guard.
return methodDeclaration.getFirstChildOrThrow(TypeGuards.isBlock)
Right now, we have to explicitly cast it (with a simple as Block
at the end).
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (5 by maintainers)
Top Results From Across the Web
Type guard function overloading is infered not properly ...
prototype.filter . When a function is passed to a parameter, could you explain how the signature is inferred from the overload of the...
Read more >5 Methods to use Type Guards in TypeScript
Type Guards come into the picture with the usage of TypeScript. This technique is used to identify or narrow down the type of...
Read more >TypeScript — Make types “real”, the type guard functions
User-Defined Type Guards: write your own Type Guard ; function argument type, like for overloads, should be as open as possible ; user...
Read more >Documentation - Advanced Types
To define a type guard, we simply need to define a function whose return type is a type ... The in operator also...
Read more >How to correctly use a type guard when looping through ...
I still need the type guard to ensure I'm on the right branch, but then I have to cast the array, dataArr as...
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
In 12.6.0.
@lazarljubenovic thanks that works!