Closed rexfordessilfie closed 1 year ago
Closing this to move to a new repository after some more thought. I will be moving this to a new repository to rework it a bit more and to have a standalone reusable wrapper library that can be used in a many different contexts, including within next.js, and all in a type-safe manner, compared to existing JS solutions. After looking round, use-cases that come to mind for useful wrappers include throttle, debounce and more. See https://github.com/tournament-js/wrappers/blob/master/wrappers.js for example
Overview
Explores adding a type-safe generic wrapper that can be applied to any kind of function without the needing to repeat wrapping logic for each kind of function (args x return) combination.
Changes
typedWrapperCreator
for creating wrapper creators with strongly typed arguments.createWrapper
for creating a wrapper that can be applied to a function.TupleExtendsInclude
to allow defining function argument types at two different levels, and either use the closest type or fallback to the more distant type. It resolves T2345. For it to work however, all types must be specified in the overridden version.next()
function return to detect when to infer the wrapped functions return type, or to use the callback's return typeCloses #19