From 70ff4da3eee5250de662c8faa3d5eb6399a48a09 Mon Sep 17 00:00:00 2001 From: Bo Miller Date: Tue, 29 Jul 2014 23:49:35 -0400 Subject: [PATCH] Underscore.js: Updated chained calls to first() so that they return a _ChainSingle instead of _Chain. This causes a future call to value() to return a single T rather than an array of T which matches underscore's behavior. --- underscore/underscore-tests.ts | 4 ++++ underscore/underscore.d.ts | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/underscore/underscore-tests.ts b/underscore/underscore-tests.ts index 11624abeb1..8b638ee508 100644 --- a/underscore/underscore-tests.ts +++ b/underscore/underscore-tests.ts @@ -328,4 +328,8 @@ function chain_tests() { .flatten() .find(num => num % 2 == 0) .value(); + + var firstVal: number = _.chain([1, 2, 3]) + .first() + .value(); } diff --git a/underscore/underscore.d.ts b/underscore/underscore.d.ts index 5b64aceb13..7d9c84f826 100644 --- a/underscore/underscore.d.ts +++ b/underscore/underscore.d.ts @@ -2620,7 +2620,7 @@ interface _Chain { * Wrapped type `any[]`. * @see _.first **/ - first(): _Chain; + first(): _ChainSingle; /** * Wrapped type `any[]`.