From f1bdd8b3df95459dca6824cea3b8cfd65d2eb9d4 Mon Sep 17 00:00:00 2001 From: basarat Date: Mon, 26 Aug 2013 22:12:06 +1000 Subject: [PATCH] added tests for angular promise chain --- angularjs/angular-tests.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/angularjs/angular-tests.ts b/angularjs/angular-tests.ts index b171da9c14..24d38aa63e 100644 --- a/angularjs/angular-tests.ts +++ b/angularjs/angular-tests.ts @@ -181,3 +181,26 @@ mod.constant(My.Namespace); mod.value('name', 23); mod.value('name', "23"); mod.value(My.Namespace); + +// Promise signature tests +var foo: ng.IPromise; +foo.then((x) => { + // x is infered to be a number. Expected + return "asdf"; +}).then((x) => { + // x is inferred to be string. Awesome + x.length; + return 123; +}).then((x) => { + // x is infered to be a number. Awesomer + x.toFixed(); + return; +}).then((x) => { + // x is infered to be void. Sounds good. + // Of course you cannot use x here (typescript will prevent you) + // Try object: + return { a: 123 }; +}).then((x) => { + // Still works + x.a = 123; +});