Skip to content

Commit 9f47b11

Browse files
authoredNov 9, 2023
Revert "PartialDeep: Ensure it doesn't recurse into prototype properties" (#743)
1 parent f31a21c commit 9f47b11

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed
 

‎source/partial-deep.d.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type {BuiltIns, UnknownRecord} from './internal';
1+
import type {BuiltIns} from './internal';
22

33
/**
44
@see PartialDeep
@@ -69,17 +69,17 @@ export type PartialDeep<T, Options extends PartialDeepOptions = {}> = T extends
6969
? PartialReadonlyMapDeep<KeyType, ValueType, Options>
7070
: T extends ReadonlySet<infer ItemType>
7171
? PartialReadonlySetDeep<ItemType, Options>
72-
: T extends UnknownRecord
73-
? PartialObjectDeep<T, Options>
74-
: T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
72+
: T extends object
73+
? T extends ReadonlyArray<infer ItemType> // Test for arrays/tuples, per https://github.com/microsoft/TypeScript/issues/35156
7574
? Options['recurseIntoArrays'] extends true
7675
? ItemType[] extends T // Test for arrays (non-tuples) specifically
7776
? readonly ItemType[] extends T // Differentiate readonly and mutable arrays
7877
? ReadonlyArray<PartialDeep<ItemType | undefined, Options>>
7978
: Array<PartialDeep<ItemType | undefined, Options>>
8079
: PartialObjectDeep<T, Options> // Tuples behave properly
8180
: T // If they don't opt into array testing, just use the original type
82-
: T;
81+
: PartialObjectDeep<T, Options>
82+
: unknown;
8383

8484
/**
8585
Same as `PartialDeep`, but accepts only `Map`s and as inputs. Internal helper for `PartialDeep`.

‎test-d/partial-deep.ts

-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ const foo = {
1010
bar: {
1111
function: (_: string): void => undefined,
1212
classConstructor: ClassA,
13-
html: document.createElement('div'),
1413
object: {key: 'value'},
1514
string: 'waldo',
1615
number: 1,
@@ -59,8 +58,6 @@ expectAssignable<ReadonlyMap<string | undefined, string | undefined> | undefined
5958
expectAssignable<ReadonlySet<string | undefined> | undefined>(partialDeepFoo.bar!.readonlySet);
6059
expectType<ReadonlyArray<string | undefined> | undefined>(partialDeepFoo.bar!.readonlyArray);
6160
expectType<readonly ['foo'?] | undefined>(partialDeepFoo.bar!.readonlyTuple);
62-
// Test for https://github.com/sindresorhus/type-fest/issues/651
63-
expectType<HTMLDivElement | undefined>(partialDeepFoo.bar!.html);
6461
// Check for compiling with omitting partial keys
6562
partialDeepFoo = {baz: 'fred'};
6663
partialDeepFoo = {bar: {string: 'waldo'}};

0 commit comments

Comments
 (0)
Please sign in to comment.