menu

redundant-closure

Disallow closures that only forward their arguments to another function

A closure that passes each parameter unchanged to one function adds another callable value and invocation without changing the call. Instead, you SHOULD pass the function directly when the forwarded arguments require no adjustments.

Reported

1declare function square(value: int32): int32;2 3function squares(values: int32[]): Iterator<int32> {4    return values.iterator().map((value) => square(value));5}

Accepted

1declare function square(value: int32): int32;2 3function squares(values: int32[]): Iterator<int32> {4    return values.iterator().map(square);5}