How to pass types to function as generics without interfering with generics/parameter inference?

This page summarizes the projects mentioned and recommended in the original post on reddit.com/r/typescript

Our great sponsors
  • Sonar - Write Clean JavaScript Code. Always.
  • Scout APM - Truly a developer’s best friend
  • Zigi - Close all those tabs. Zigi will handle your updates.
  • InfluxDB - Build time-series-based applications quickly and at scale.
  • TypeScript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

    Unfortunately, TypeScript doesn’t currently support partial inference. See this GitHub PR for more information. One [ugly] way to get around it is to wrap your function in another function so that TypeScript can infer the generic from one and you can specify the other explicitly. Of course, this affects how you call the function as well, so YMMV.

  • Sonar

    Write Clean JavaScript Code. Always.. Sonar helps you commit clean code every time. With over 300 unique rules to find JavaScript bugs, code smells & vulnerabilities, Sonar finds the issues while you focus on the work.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts