question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add explicit type parameters to ignore functions

See original GitHub issue

I’d like for ignore functions like AsyncResult.ignore (and perhaps ignoreError?) to accept explicit type parameters, just like F#'s ignore function.

My reasoning is that ignoring input is a “dangerous” operation under refactoring. For example:

doSomething |> ignore<int>

If you change doSomething so that it no longer returns int, then that may indicate that the code that previously ignored its result should now do something else with it. If you just specify ignore, you have to remember to check this yourself. If you specify an explicit type parameter, the compiler checks this for you and you have to decide in each case whether to ignore the new return type or do something else.

It is currently not possible to use explicit type parameters with e.g. AsyncResult.ignore because the definition does not use explicit type parameters. If this is changed, we can use explicit type parameters, e.g. AsyncResult.ignore<int, _>.

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cmeerencommented, Apr 4, 2022

We can even enforce it as a compiler check using RequiresExplicitTypeArguments

Cool, I didn’t know about that. But I don’t think we should force this on users.

1reaction
cmeerencommented, Apr 4, 2022

Indeed they do. Did you mean that was relevant for the handling of this issue?

Edit: Of course, it is relevant in the sense that explicitly specifying the type to ignore would avoid that issue since it wouldn’t compile.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How exclude undesireble function type as argument?
E.g. these would be equivalent: const withGeneric = f<unknown>(new Map()); const simpleCast: unknown = f(new Map());
Read more >
Remove warning about explicit type parameters when it's a ...
I propose we remove this warning when there is only one type parameter (which is in my experience 95% of the cases) :...
Read more >
Documentation - More on Functions
TypeScript behaves the same way. Functions with fewer parameters (of the same types) can always take the place of functions with more parameters....
Read more >
explicit-function-return-type
Require explicit return types on functions and class methods. ... Whether to ignore functions that don't have generic type parameters. */
Read more >
Parametric Types | Epic Developer Community
Use parametric types as explicit type arguments to classes or functions, or as implicit type arguments to functions.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found