mirror of
https://github.com/FlipsideCrypto/DefinitelyTyped.git
synced 2026-02-06 10:56:53 +00:00
🤖 Merge PR #46650 [@types/underscore] Support readonly tuples in object calls by @reubenrybnik
This commit is contained in:
parent
5ed5e96492
commit
aba9d5faa5
2
types/underscore/index.d.ts
vendored
2
types/underscore/index.d.ts
vendored
@ -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;
|
||||
|
||||
|
||||
@ -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 = {};
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user