TypeScript generic function loses type inference when passed as a callback | Vurso