Search Posts

return type of method with nested promises

I am getting error from resharper

Cannot convert type ‘IPromise < IPromise < void > >’ to type
‘IPromise < void >’: Types of property ‘then’ of types ‘IPromise < void >’
and ‘IPromise < IPromise < void > >’ are incompatible

but if I compile the project using tsc from command line I am not getting any error. As I understand the nested promises are being handled by angular and the calling method does not have to check for nested then

example code

private somemethod(): ng.IPromise<void> {
        return this.promiseOuter().then(this.promiseInner);

private promiseOuter = (): ng.IPromise<void> => { }

private promiseInner = (): ng.IPromise<void> => { }

so what really is return type: is it promise< void> or promise< promise <void>>

Source: AngularJS

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.