Note: due to the issue noted in Closures over types are type unstable, one must capture T
using a where
, rather than using typeof
. The aforementioned issue addresses the case where this is not possible – I don’t have a solution in this case yet.