Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion types/underscore/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ declare module _ {
// if T is a list, assume that it contains pairs of some type, so any
// if T isn't a list, there's no way that it can provide pairs, so never
type PairValue<T> =
T extends [EnumerableKey, infer TValue] ? TValue
T extends Readonly<[EnumerableKey, infer TValue]> ? TValue
: T extends List<infer TValue> ? TValue
: never;

Expand Down
7 changes: 7 additions & 0 deletions types/underscore/underscore-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,13 @@ _.chain([1, 3, 5])
.intersection([2, 4, 6, 8], [4, 8])
.value();

// "as const" isn't supported until TS3.4; the Readonly assertion below mimics its effect
// $ExpectType Dictionary<number>
_.chain([{ id: 1, name: 'a' }, { id: 2, name: 'b' }])
.map(o => [o.name, o.id] as Readonly<[string, number]>)
.object()
.value();

// common testing types and objects
const context = {};

Expand Down