🤖 Merge PR #46650 [@types/underscore] Support readonly tuples in object calls by @reubenrybnik

This commit is contained in:
Michael Ness 2020-08-11 13:40:04 -07:00 committed by GitHub
parent 5ed5e96492
commit aba9d5faa5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 1 deletions

View File

@ -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;

View File

@ -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 = {};