Skip to content

Commit abe1df7

Browse files
committed
Removing the EnumerableKey type alias because DT linting is not good at dealing with it between different versions of TypeScript.
1 parent 48453c0 commit abe1df7

2 files changed

Lines changed: 18 additions & 20 deletions

File tree

types/underscore/index.d.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,6 @@ declare module _ {
8383

8484
type Collection<T> = List<T> | Dictionary<T>;
8585

86-
type EnumerableKey = string | number;
87-
8886
type CollectionKey<V> =
8987
V extends never ? any
9088
: V extends List<any> ? number
@@ -106,16 +104,16 @@ declare module _ {
106104

107105
type Iteratee<V, R, T extends TypeOfCollection<V, any> = TypeOfCollection<V>> =
108106
CollectionIterator<T, R, V> |
109-
EnumerableKey |
110-
EnumerableKey[] |
107+
string | number |
108+
(string | number)[] |
111109
Partial<T> |
112110
null |
113111
undefined;
114112

115113
type IterateeResult<I, T> =
116114
I extends (...args: any[]) => infer R ? R
117115
: I extends keyof T ? T[I]
118-
: I extends EnumerableKey | EnumerableKey[] ? any
116+
: I extends string | number | (string | number)[] ? any
119117
: I extends object ? boolean
120118
: I extends null | undefined ? T
121119
: never;
@@ -158,7 +156,7 @@ declare module _ {
158156
// if T is a list, assume that it contains pairs of some type, so any
159157
// if T isn't a list, there's no way that it can provide pairs, so never
160158
type PairValue<T> =
161-
T extends Readonly<[EnumerableKey, infer TValue]> ? TValue
159+
T extends Readonly<[string | number, infer TValue]> ? TValue
162160
: T extends List<infer TValue> ? TValue
163161
: never;
164162

@@ -488,7 +486,7 @@ declare module _ {
488486
* @returns The set of values for the specified `propertyName` for each
489487
* item in `collection`.
490488
**/
491-
pluck<V extends Collection<any>, K extends EnumerableKey>(
489+
pluck<V extends Collection<any>, K extends string | number>(
492490
collection: V,
493491
propertyName: K
494492
): PropertyTypeOrAny<TypeOfCollection<V>, K>[];
@@ -558,7 +556,7 @@ declare module _ {
558556
**/
559557
groupBy<V extends Collection<any>>(
560558
collection: V,
561-
iteratee?: Iteratee<V, EnumerableKey>,
559+
iteratee?: Iteratee<V, string | number>,
562560
context?: any
563561
): Dictionary<TypeOfCollection<V>[]>;
564562

@@ -576,7 +574,7 @@ declare module _ {
576574
**/
577575
indexBy<V extends Collection<any>>(
578576
collection: V,
579-
iteratee?: Iteratee<V, EnumerableKey>,
577+
iteratee?: Iteratee<V, string | number>,
580578
context?: any): Dictionary<TypeOfCollection<V>>;
581579

582580
/**
@@ -594,7 +592,7 @@ declare module _ {
594592
**/
595593
countBy<V extends Collection<any>>(
596594
collection: V,
597-
iteratee?: Iteratee<V, EnumerableKey>,
595+
iteratee?: Iteratee<V, string | number>,
598596
context?: any
599597
): Dictionary<number>;
600598

@@ -873,7 +871,7 @@ declare module _ {
873871
* corresponding to those keys.
874872
* @returns An object comprised of the provided keys and values.
875873
**/
876-
object<TList extends List<EnumerableKey>, TValue>(
874+
object<TList extends List<string | number>, TValue>(
877875
list: TList,
878876
values: List<TValue>
879877
): Dictionary<TValue | undefined>;
@@ -4258,7 +4256,7 @@ declare module _ {
42584256
* @returns The set of values for the specified `propertyName` for each
42594257
* item in the wrapped collection.
42604258
**/
4261-
pluck<K extends EnumerableKey>(
4259+
pluck<K extends string | number>(
42624260
propertyName: K
42634261
): PropertyTypeOrAny<T, K>[];
42644262

@@ -4314,7 +4312,7 @@ declare module _ {
43144312
* the wrapped collection.
43154313
**/
43164314
groupBy(
4317-
iteratee?: Iteratee<V, EnumerableKey>,
4315+
iteratee?: Iteratee<V, string | number>,
43184316
context?: any
43194317
): Dictionary<T[]>;
43204318

@@ -4329,7 +4327,7 @@ declare module _ {
43294327
* @returns A dictionary where each item in the wrapped collection is
43304328
* assigned to the property designated by `iteratee`.
43314329
**/
4332-
indexBy(iteratee?: Iteratee<V, EnumerableKey>, context?: any): Dictionary<T>;
4330+
indexBy(iteratee?: Iteratee<V, string | number>, context?: any): Dictionary<T>;
43334331

43344332
/**
43354333
* Sorts the wrapped collection into groups and returns a count for the
@@ -4344,7 +4342,7 @@ declare module _ {
43444342
* elements from the wrapped collection.
43454343
**/
43464344
countBy(
4347-
iteratee?: Iteratee<V, EnumerableKey>,
4345+
iteratee?: Iteratee<V, string | number>,
43484346
context?: any
43494347
): Dictionary<number>;
43504348

@@ -5441,7 +5439,7 @@ declare module _ {
54415439
* @returns A chain wrapper around The set of values for the specified
54425440
* `propertyName` for each item in the wrapped collection.
54435441
**/
5444-
pluck<K extends EnumerableKey>(
5442+
pluck<K extends string | number>(
54455443
propertyName: K
54465444
): _Chain<PropertyTypeOrAny<T, K>>;
54475445

@@ -5506,7 +5504,7 @@ declare module _ {
55065504
* the grouped elements from the wrapped collection.
55075505
**/
55085506
groupBy(
5509-
iteratee?: Iteratee<V, EnumerableKey>,
5507+
iteratee?: Iteratee<V, string | number>,
55105508
context?: any
55115509
): _Chain<T[], Dictionary<T[]>>;
55125510

@@ -5523,7 +5521,7 @@ declare module _ {
55235521
* `iteratee`.
55245522
**/
55255523
indexBy(
5526-
iteratee?: Iteratee<V, EnumerableKey>,
5524+
iteratee?: Iteratee<V, string | number>,
55275525
context?: any
55285526
): _Chain<T, Dictionary<T>>;
55295527

@@ -5540,7 +5538,7 @@ declare module _ {
55405538
* the count of the grouped elements from the wrapped collection.
55415539
**/
55425540
countBy(
5543-
iterator?: Iteratee<V, EnumerableKey>,
5541+
iterator?: Iteratee<V, string | number>,
55445542
context?: any
55455543
): _Chain<number, Dictionary<number>>;
55465544

types/underscore/underscore-tests.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,7 @@ knownShallowPropertyResult; // $ExpectType string | StringRecord
10231023
declare const unknownShallowPropertyResult: _.IterateeResult<typeof shallowProperty, NonIntersecting>;
10241024
unknownShallowPropertyResult; // $ExpectType any
10251025

1026-
declare const deepPropertyResult: _.IterateeResult<_.EnumerableKey[], StringRecord>;
1026+
declare const deepPropertyResult: _.IterateeResult<(string | number)[], StringRecord>;
10271027
deepPropertyResult; // $ExpectType any
10281028

10291029
declare const nullResult: _.IterateeResult<null, StringRecord>;

0 commit comments

Comments
 (0)