Skip to content

Commit 80ea8e1

Browse files
authored
Merge pull request #19 from graphemecluster/purne-check-non-nullable
Purne `CheckNonNullable`
2 parents f8964af + 71b3ce6 commit 80ea8e1

14 files changed

+112
-120
lines changed

docs/diff/es2015.core.d.ts.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ Index: es2015.core.d.ts
9191
* target object. Returns the target object.
9292
* @param target The target object to copy to.
9393
- * @param source The source object from which to copy properties.
94-
- */
94+
+ * @param sources One or more source objects from which to copy properties
95+
*/
9596
- assign<T extends {}, U>(target: T, source: U): T & U;
9697
-
9798
- /**
@@ -112,30 +113,29 @@ Index: es2015.core.d.ts
112113
- * @param source3 The third source object from which to copy properties.
113114
- */
114115
- assign<T extends {}, U, V, W>(
115-
- target: T,
116+
+ assign<T extends {}, Ts extends readonly any[]>(
117+
target: T,
116118
- source1: U,
117119
- source2: V,
118120
- source3: W
119121
- ): T & U & V & W;
120-
-
121-
- /**
122-
- * Copy the values of all of the enumerable own properties from one or more source objects to a
123-
- * target object. Returns the target object.
124-
- * @param target The target object to copy to.
125-
* @param sources One or more source objects from which to copy properties
126-
*/
127-
- assign(target: object, ...sources: any[]): any;
128-
+ assign<T, Ts extends readonly any[]>(
129-
+ target: CheckNonNullable<T>,
130122
+ ...sources: Ts
131123
+ ): Intersect<[T, ...Ts]>;
132124

133125
/**
126+
- * Copy the values of all of the enumerable own properties from one or more source objects to a
127+
- * target object. Returns the target object.
128+
- * @param target The target object to copy to.
129+
- * @param sources One or more source objects from which to copy properties
130+
- */
131+
- assign(target: object, ...sources: any[]): any;
132+
-
133+
- /**
134134
* Returns an array of all symbol properties found directly on object o.
135135
* @param o Object to retrieve the symbols from.
136136
*/
137137
- getOwnPropertySymbols(o: any): symbol[];
138-
+ getOwnPropertySymbols<T>(o: CheckNonNullable<T>): symbol[];
138+
+ getOwnPropertySymbols(o: {}): symbol[];
139139

140140
/**
141141
* Returns the names of the enumerable string properties and methods of an object.

docs/diff/es2017.object.d.ts.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Index: es2017.object.d.ts
55
===================================================================
66
--- es2017.object.d.ts
77
+++ es2017.object.d.ts
8-
@@ -2,34 +2,42 @@
8+
@@ -2,34 +2,44 @@
99
/**
1010
* Returns an array of values of the enumerable properties of an object
1111
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
@@ -23,7 +23,7 @@ Index: es2017.object.d.ts
2323
+ * Returns an array of values of the enumerable properties of an object
2424
+ * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
2525
+ */
26-
+ values<T>(o: CheckNonNullable<T>): unknown[];
26+
+ values(o: {}): unknown[];
2727

2828
/**
2929
* Returns an array of key/values of the enumerable properties of an object
@@ -42,17 +42,18 @@ Index: es2017.object.d.ts
4242
+ * Returns an array of key/values of the enumerable properties of an object
4343
+ * @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
4444
+ */
45-
+ entries<T>(o: CheckNonNullable<T>): [string, unknown][];
45+
+ entries(o: {}): [string, unknown][];
4646

4747
/**
4848
* Returns an object containing all own property descriptors of an object
4949
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
5050
*/
5151
- getOwnPropertyDescriptors<T>(
52-
- o: T
52+
+ getOwnPropertyDescriptors<T extends {}>(
53+
o: T
5354
- ): { [P in keyof T]: TypedPropertyDescriptor<T[P]> } & {
5455
- [x: string]: PropertyDescriptor;
55-
+ getOwnPropertyDescriptors<T>(o: CheckNonNullable<T>): {
56+
+ ): {
5657
+ [P in keyof T]: TypedPropertyDescriptor<T[P]>;
5758
+ } & {
5859
+ [x: PropertyKey]: PropertyDescriptor;

docs/diff/es5.d.ts.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,17 @@ Index: es5.d.ts
6464
* @param o The object that references the prototype.
6565
*/
6666
- getPrototypeOf(o: any): any;
67-
+ getPrototypeOf<T>(o: CheckNonNullable<T>): unknown;
67+
+ getPrototypeOf(o: {}): unknown;
6868

6969
/**
7070
* Gets the own property descriptor of the specified object.
7171
* An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
7272
* @param o Object that contains the property.
7373
* @param p Name of the property.
7474
*/
75-
- getOwnPropertyDescriptor(
75+
getOwnPropertyDescriptor(
7676
- o: any,
77-
+ getOwnPropertyDescriptor<T>(
78-
+ o: CheckNonNullable<T>,
77+
+ o: {},
7978
p: PropertyKey
8079
): PropertyDescriptor | undefined;
8180

@@ -85,7 +84,7 @@ Index: es5.d.ts
8584
* @param o Object that contains the own properties.
8685
*/
8786
- getOwnPropertyNames(o: any): string[];
88-
+ getOwnPropertyNames<T>(o: CheckNonNullable<T>): string[];
87+
+ getOwnPropertyNames(o: {}): string[];
8988

9089
/**
9190
* Creates an object that has the specified prototype or that has null prototype.
@@ -3557,7 +3556,7 @@ Index: es5.d.ts
35573556
}
35583557
declare var Float64Array: Float64ArrayConstructor;
35593558

3560-
@@ -5536,4 +5418,31 @@
3559+
@@ -5536,4 +5418,29 @@
35613560
locales?: string | string[],
35623561
options?: Intl.DateTimeFormatOptions
35633562
): string;
@@ -3578,8 +3577,6 @@ Index: es5.d.ts
35783577
+ ? S
35793578
+ : never;
35803579
+
3581-
+type CheckNonNullable<T> = [T] extends [null | undefined] ? never : T;
3582-
+
35833580
+type JSONValue =
35843581
+ | null
35853582
+ | string

generated/lib.es2015.core.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -319,16 +319,16 @@ interface ObjectConstructor {
319319
* @param target The target object to copy to.
320320
* @param sources One or more source objects from which to copy properties
321321
*/
322-
assign<T, Ts extends readonly any[]>(
323-
target: CheckNonNullable<T>,
322+
assign<T extends {}, Ts extends readonly any[]>(
323+
target: T,
324324
...sources: Ts
325325
): Intersect<[T, ...Ts]>;
326326

327327
/**
328328
* Returns an array of all symbol properties found directly on object o.
329329
* @param o Object to retrieve the symbols from.
330330
*/
331-
getOwnPropertySymbols<T>(o: CheckNonNullable<T>): symbol[];
331+
getOwnPropertySymbols(o: {}): symbol[];
332332

333333
/**
334334
* Returns the names of the enumerable string properties and methods of an object.

generated/lib.es2017.object.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface ObjectConstructor {
1313
* Returns an array of values of the enumerable properties of an object
1414
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
1515
*/
16-
values<T>(o: CheckNonNullable<T>): unknown[];
16+
values(o: {}): unknown[];
1717

1818
/**
1919
* Returns an array of key/values of the enumerable properties of an object
@@ -29,13 +29,15 @@ interface ObjectConstructor {
2929
* Returns an array of key/values of the enumerable properties of an object
3030
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
3131
*/
32-
entries<T>(o: CheckNonNullable<T>): [string, unknown][];
32+
entries(o: {}): [string, unknown][];
3333

3434
/**
3535
* Returns an object containing all own property descriptors of an object
3636
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
3737
*/
38-
getOwnPropertyDescriptors<T>(o: CheckNonNullable<T>): {
38+
getOwnPropertyDescriptors<T extends {}>(
39+
o: T
40+
): {
3941
[P in keyof T]: TypedPropertyDescriptor<T[P]>;
4042
} & {
4143
[x: PropertyKey]: PropertyDescriptor;

generated/lib.es5.d.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,16 +168,16 @@ interface ObjectConstructor {
168168
* Returns the prototype of an object.
169169
* @param o The object that references the prototype.
170170
*/
171-
getPrototypeOf<T>(o: CheckNonNullable<T>): unknown;
171+
getPrototypeOf(o: {}): unknown;
172172

173173
/**
174174
* Gets the own property descriptor of the specified object.
175175
* An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
176176
* @param o Object that contains the property.
177177
* @param p Name of the property.
178178
*/
179-
getOwnPropertyDescriptor<T>(
180-
o: CheckNonNullable<T>,
179+
getOwnPropertyDescriptor(
180+
o: {},
181181
p: PropertyKey
182182
): PropertyDescriptor | undefined;
183183

@@ -186,7 +186,7 @@ interface ObjectConstructor {
186186
* on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions.
187187
* @param o Object that contains the own properties.
188188
*/
189-
getOwnPropertyNames<T>(o: CheckNonNullable<T>): string[];
189+
getOwnPropertyNames(o: {}): string[];
190190

191191
/**
192192
* Creates an object that has the specified prototype or that has null prototype.
@@ -6810,8 +6810,6 @@ type Intersect<T extends readonly any[]> = ((
68106810
? S
68116811
: never;
68126812

6813-
type CheckNonNullable<T> = [T] extends [null | undefined] ? never : T;
6814-
68156813
type JSONValue =
68166814
| null
68176815
| string

lib/lib.es2015.core.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,16 @@ interface ObjectConstructor {
6969
* @param target The target object to copy to.
7070
* @param sources One or more source objects from which to copy properties
7171
*/
72-
assign<T, Ts extends readonly any[]>(
73-
target: CheckNonNullable<T>,
72+
assign<T extends {}, Ts extends readonly any[]>(
73+
target: T,
7474
...sources: Ts
7575
): Intersect<[T, ...Ts]>;
7676

7777
/**
7878
* Returns an array of all symbol properties found directly on object o.
7979
* @param o Object to retrieve the symbols from.
8080
*/
81-
getOwnPropertySymbols<T>(o: CheckNonNullable<T>): symbol[];
81+
getOwnPropertySymbols(o: {}): symbol[];
8282

8383
/**
8484
* Returns true if the values are the same value, false otherwise.

lib/lib.es2017.object.d.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ interface ObjectConstructor {
1313
* Returns an array of values of the enumerable properties of an object
1414
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
1515
*/
16-
values<T>(o: CheckNonNullable<T>): unknown[];
16+
values(o: {}): unknown[];
1717

1818
/**
1919
* Returns an array of key/values of the enumerable properties of an object
@@ -29,13 +29,15 @@ interface ObjectConstructor {
2929
* Returns an array of key/values of the enumerable properties of an object
3030
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
3131
*/
32-
entries<T>(o: CheckNonNullable<T>): [string, unknown][];
32+
entries(o: {}): [string, unknown][];
3333

3434
/**
3535
* Returns an object containing all own property descriptors of an object
3636
* @param o Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
3737
*/
38-
getOwnPropertyDescriptors<T>(o: CheckNonNullable<T>): {
38+
getOwnPropertyDescriptors<T extends {}>(
39+
o: T
40+
): {
3941
[P in keyof T]: TypedPropertyDescriptor<T[P]>;
4042
} & {
4143
[x: PropertyKey]: PropertyDescriptor;

lib/lib.es5.d.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ type Intersect<T extends readonly any[]> = ((
1313
? S
1414
: never;
1515

16-
type CheckNonNullable<T> = [T] extends [null | undefined] ? never : T;
17-
1816
/**
1917
* Evaluates JavaScript code and executes it.
2018
* @param x A String value that contains valid JavaScript code.
@@ -49,16 +47,16 @@ interface ObjectConstructor {
4947
* Returns the prototype of an object.
5048
* @param o The object that references the prototype.
5149
*/
52-
getPrototypeOf<T>(o: CheckNonNullable<T>): unknown;
50+
getPrototypeOf(o: {}): unknown;
5351

5452
/**
5553
* Gets the own property descriptor of the specified object.
5654
* An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
5755
* @param o Object that contains the property.
5856
* @param p Name of the property.
5957
*/
60-
getOwnPropertyDescriptor<T>(
61-
o: CheckNonNullable<T>,
58+
getOwnPropertyDescriptor(
59+
o: {},
6260
p: PropertyKey
6361
): PropertyDescriptor | undefined;
6462

@@ -67,7 +65,7 @@ interface ObjectConstructor {
6765
* on that object, and are not inherited from the object's prototype. The properties of an object include both fields (objects) and functions.
6866
* @param o Object that contains the own properties.
6967
*/
70-
getOwnPropertyNames<T>(o: CheckNonNullable<T>): string[];
68+
getOwnPropertyNames(o: {}): string[];
7169

7270
/**
7371
* Creates an object that has the specified prototype or that has null prototype.

0 commit comments

Comments
 (0)