Changed order of IHttpPromise.then for promise chaining

previously the following code resulted in tmp beeing of type:
ng.IPromise<ng.IPromise<{}>> but it should be just ng.IPromise<{}>:

var tmp = this.$http.get('').then((result) => this.$q.defer().promise);
This commit is contained in:
Herbert Poul
2014-06-27 10:48:30 +02:00
parent 87fba9fea2
commit e839251ce9
2 changed files with 12 additions and 1 deletions

View File

@@ -220,6 +220,17 @@ foo.then((x) => {
});
var httpFoo: ng.IHttpPromise<number>;
httpFoo.then((x) => {
// When returning a promise the generic type must be inferred.
var innerPromise : ng.IPromise<number>;
return innerPromise;
}).then((x) => {
// must still be number.
x.toFixed();
});
// angular.element() tests
var element = angular.element("div.myApp");
var scope: ng.IScope = element.scope();

View File

@@ -801,8 +801,8 @@ declare module ng {
interface IHttpPromise<T> extends IPromise<T> {
success(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
error(callback: IHttpPromiseCallback<T>): IHttpPromise<T>;
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise<TResult>;
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => IPromise<TResult>, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise<TResult>;
then<TResult>(successCallback: (response: IHttpPromiseCallbackArg<T>) => TResult, errorCallback?: (response: IHttpPromiseCallbackArg<T>) => any): IPromise<TResult>;
}
interface IHttpProvider extends IServiceProvider {