Skip to content

Commit 5b7d7c2

Browse files
sandersnKonch Roman
authored andcommitted
Remove PartialDeep from lodash, replace with Partial (DefinitelyTyped#35848)
* Remove PartialDeep from lodash, replace w/Partial Fixes the most common occurrence of microsoft/TypeScript#21592. I don't think anybody uses the full capability of `PartialDeep` as a parameter, and it doesn't really make sense as the return type of `pick`. * Use PartialObject name instead of GlobalPartial
1 parent 5677607 commit 5b7d7c2

File tree

5 files changed

+11
-14
lines changed

5 files changed

+11
-14
lines changed

types/lodash/ts3.1/common/collection.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,7 @@ declare module "../index" {
13421342
/**
13431343
* @see _.orderBy
13441344
*/
1345-
orderBy(iteratees?: Many<ListIterator<T, NotVoid> | PropertyName | PartialDeep<T>>, orders?: Many<boolean|"asc"|"desc">): Collection<T>;
1345+
orderBy(iteratees?: Many<ListIterator<T, NotVoid> | PropertyName | PartialObject<T>>, orders?: Many<boolean|"asc"|"desc">): Collection<T>;
13461346
}
13471347
interface Object<T> {
13481348
/**
@@ -1354,7 +1354,7 @@ declare module "../index" {
13541354
/**
13551355
* @see _.orderBy
13561356
*/
1357-
orderBy(iteratees?: Many<ListIterator<T, NotVoid> | PropertyName | PartialDeep<T>>, orders?: Many<boolean|"asc"|"desc">): CollectionChain<T>;
1357+
orderBy(iteratees?: Many<ListIterator<T, NotVoid> | PropertyName | PartialObject<T>>, orders?: Many<boolean|"asc"|"desc">): CollectionChain<T>;
13581358
}
13591359
interface ObjectChain<T> {
13601360
/**

types/lodash/ts3.1/common/common.d.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ declare module "../index" {
210210
interface PrimitiveChain<T> extends LoDashExplicitWrapper<T> {
211211
}
212212
type NotVoid = unknown;
213-
type IterateeShorthand<T> = PropertyName | [PropertyName, any] | PartialDeep<T>;
213+
type IterateeShorthand<T> = PropertyName | [PropertyName, any] | PartialObject<T>;
214214
type ArrayIterator<T, TResult> = (value: T, index: number, collection: T[]) => TResult;
215215
type ListIterator<T, TResult> = (value: T, index: number, collection: List<T>) => TResult;
216216
type ListIteratee<T> = ListIterator<T, NotVoid> | IterateeShorthand<T>;
@@ -258,9 +258,6 @@ declare module "../index" {
258258
cancel(): void;
259259
flush(): void;
260260
}
261-
type PartialDeep<T> = {
262-
[P in keyof T]?: PartialDeep<T[P]>;
263-
};
264261
// For backwards compatibility
265262
type LoDashImplicitArrayWrapper<T> = LoDashImplicitWrapper<T[]>;
266263
type LoDashImplicitNillableArrayWrapper<T> = LoDashImplicitWrapper<T[] | null | undefined>;

types/lodash/ts3.1/common/object.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1902,7 +1902,7 @@ declare module "../index" {
19021902
/**
19031903
* @see _.pick
19041904
*/
1905-
pick<T>(object: T | null | undefined, ...props: PropertyPath[]): PartialDeep<T>;
1905+
pick<T>(object: T | null | undefined, ...props: PropertyPath[]): PartialObject<T>;
19061906
}
19071907
interface Object<T> {
19081908
/**

types/lodash/ts3.1/fp.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2747,12 +2747,12 @@ declare namespace _ {
27472747
<T extends object, U extends keyof T>(props: lodash.Many<U>, object: T): Pick<T, U>;
27482748
(props: lodash.PropertyPath): LodashPick2x1;
27492749
<T>(props: lodash.__, object: T | null | undefined): LodashPick2x2<T>;
2750-
<T>(props: lodash.PropertyPath, object: T | null | undefined): lodash.PartialDeep<T>;
2750+
<T>(props: lodash.PropertyPath, object: T | null | undefined): lodash.PartialObject<T>;
27512751
}
27522752
type LodashPick1x1<T, U extends keyof T> = (object: T) => Pick<T, U>;
27532753
type LodashPick1x2<T> = <U extends keyof T>(props: lodash.Many<U>) => Pick<T, U>;
2754-
type LodashPick2x1 = <T>(object: T | null | undefined) => lodash.PartialDeep<T>;
2755-
type LodashPick2x2<T> = (props: lodash.PropertyPath) => lodash.PartialDeep<T>;
2754+
type LodashPick2x1 = <T>(object: T | null | undefined) => lodash.PartialObject<T>;
2755+
type LodashPick2x2<T> = (props: lodash.PropertyPath) => lodash.PartialObject<T>;
27562756
interface LodashPickBy {
27572757
<T, S extends T>(predicate: lodash.ValueKeyIterateeTypeGuard<T, S>): LodashPickBy1x1<T, S>;
27582758
<T>(predicate: lodash.__, object: lodash.Dictionary<T> | null | undefined): LodashPickBy1x2<T>;

types/lodash/ts3.1/lodash-tests.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5623,10 +5623,10 @@ fp.now(); // $ExpectType number
56235623
const literalsArray: Array<"a" | "b"> = ["a", "b"];
56245624
const roLiteralsArray: ReadonlyArray<"a" | "b"> = literalsArray;
56255625

5626-
_.pick(obj1, "a"); // $ExpectType PartialDeep<AbcObject>
5627-
_.pick(obj1, 0, "a"); // $ExpectType PartialDeep<AbcObject>
5628-
_.pick(obj1, ["b", 1], 0, "a"); // $ExpectType PartialDeep<AbcObject>
5629-
_.pick(obj1, readonlyArray); // $ExpectType PartialDeep<AbcObject>
5626+
_.pick(obj1, "a"); // $ExpectType Partial<AbcObject>
5627+
_.pick(obj1, 0, "a"); // $ExpectType Partial<AbcObject>
5628+
_.pick(obj1, ["b", 1], 0, "a"); // $ExpectType Partial<AbcObject>
5629+
_.pick(obj1, readonlyArray); // $ExpectType Partial<AbcObject>
56305630
_.pick(obj2, "a", "b"); // $ExpectType Pick<AbcObject, "a" | "b">
56315631
// We can't use ExpectType here because typescript keeps changing what order the types appear.
56325632
let result1: Pick<AbcObject, "a" | "b">;

0 commit comments

Comments
 (0)