AngularJS: typing the Q.defer method