Added generic typing to jQuery.when