Skip to content

Prune CheckNonNullable #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions docs/diff/es2015.core.d.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ Index: es2015.core.d.ts
* target object. Returns the target object.
* @param target The target object to copy to.
- * @param source The source object from which to copy properties.
- */
+ * @param sources One or more source objects from which to copy properties
*/
- assign<T extends {}, U>(target: T, source: U): T & U;
-
- /**
Expand All @@ -112,30 +113,29 @@ Index: es2015.core.d.ts
- * @param source3 The third source object from which to copy properties.
- */
- assign<T extends {}, U, V, W>(
- target: T,
+ assign<T extends {}, Ts extends readonly any[]>(
target: T,
- source1: U,
- source2: V,
- source3: W
- ): T & U & V & W;
-
- /**
- * Copy the values of all of the enumerable own properties from one or more source objects to a
- * target object. Returns the target object.
- * @param target The target object to copy to.
* @param sources One or more source objects from which to copy properties
*/
- assign(target: object, ...sources: any[]): any;
+ assign<T, Ts extends readonly any[]>(
+ target: CheckNonNullable<T>,
+ ...sources: Ts
+ ): Intersect<[T, ...Ts]>;

/**
- * Copy the values of all of the enumerable own properties from one or more source objects to a
- * target object. Returns the target object.
- * @param target The target object to copy to.
- * @param sources One or more source objects from which to copy properties
- */
- assign(target: object, ...sources: any[]): any;
-
- /**
* Returns an array of all symbol properties found directly on object o.
* @param o Object to retrieve the symbols from.
*/
- getOwnPropertySymbols(o: any): symbol[];
+ getOwnPropertySymbols<T>(o: CheckNonNullable<T>): symbol[];
+ getOwnPropertySymbols(o: {}): symbol[];

/**
* Returns the names of the enumerable string properties and methods of an object.
Expand Down
11 changes: 6 additions & 5 deletions docs/diff/es2017.object.d.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Index: es2017.object.d.ts
===================================================================
--- es2017.object.d.ts
+++ es2017.object.d.ts
@@ -2,34 +2,42 @@
@@ -2,34 +2,44 @@
/**
* Returns an array of values of the enumerable properties of an object
* @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.
Expand All @@ -23,7 +23,7 @@ Index: es2017.object.d.ts
+ * Returns an array of values of the enumerable properties of an object
+ * @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.
+ */
+ values<T>(o: CheckNonNullable<T>): unknown[];
+ values(o: {}): unknown[];

/**
* Returns an array of key/values of the enumerable properties of an object
Expand All @@ -42,17 +42,18 @@ Index: es2017.object.d.ts
+ * Returns an array of key/values of the enumerable properties of an object
+ * @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.
+ */
+ entries<T>(o: CheckNonNullable<T>): [string, unknown][];
+ entries(o: {}): [string, unknown][];

/**
* Returns an object containing all own property descriptors of an object
* @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.
*/
- getOwnPropertyDescriptors<T>(
- o: T
+ getOwnPropertyDescriptors<T extends {}>(
o: T
- ): { [P in keyof T]: TypedPropertyDescriptor<T[P]> } & {
- [x: string]: PropertyDescriptor;
+ getOwnPropertyDescriptors<T>(o: CheckNonNullable<T>): {
+ ): {
+ [P in keyof T]: TypedPropertyDescriptor<T[P]>;
+ } & {
+ [x: PropertyKey]: PropertyDescriptor;
Expand Down
13 changes: 5 additions & 8 deletions docs/diff/es5.d.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,18 +64,17 @@ Index: es5.d.ts
* @param o The object that references the prototype.
*/
- getPrototypeOf(o: any): any;
+ getPrototypeOf<T>(o: CheckNonNullable<T>): unknown;
+ getPrototypeOf(o: {}): unknown;

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

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

/**
* Creates an object that has the specified prototype or that has null prototype.
Expand Down Expand Up @@ -3557,7 +3556,7 @@ Index: es5.d.ts
}
declare var Float64Array: Float64ArrayConstructor;

@@ -5536,4 +5418,31 @@
@@ -5536,4 +5418,29 @@
locales?: string | string[],
options?: Intl.DateTimeFormatOptions
): string;
Expand All @@ -3578,8 +3577,6 @@ Index: es5.d.ts
+ ? S
+ : never;
+
+type CheckNonNullable<T> = [T] extends [null | undefined] ? never : T;
+
+type JSONValue =
+ | null
+ | string
Expand Down
6 changes: 3 additions & 3 deletions generated/lib.es2015.core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,16 +319,16 @@ interface ObjectConstructor {
* @param target The target object to copy to.
* @param sources One or more source objects from which to copy properties
*/
assign<T, Ts extends readonly any[]>(
target: CheckNonNullable<T>,
assign<T extends {}, Ts extends readonly any[]>(
target: T,
...sources: Ts
): Intersect<[T, ...Ts]>;

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

/**
* Returns the names of the enumerable string properties and methods of an object.
Expand Down
8 changes: 5 additions & 3 deletions generated/lib.es2017.object.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface ObjectConstructor {
* Returns an array of values of the enumerable properties of an object
* @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.
*/
values<T>(o: CheckNonNullable<T>): unknown[];
values(o: {}): unknown[];

/**
* Returns an array of key/values of the enumerable properties of an object
Expand All @@ -29,13 +29,15 @@ interface ObjectConstructor {
* Returns an array of key/values of the enumerable properties of an object
* @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.
*/
entries<T>(o: CheckNonNullable<T>): [string, unknown][];
entries(o: {}): [string, unknown][];

/**
* Returns an object containing all own property descriptors of an object
* @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.
*/
getOwnPropertyDescriptors<T>(o: CheckNonNullable<T>): {
getOwnPropertyDescriptors<T extends {}>(
o: T
): {
[P in keyof T]: TypedPropertyDescriptor<T[P]>;
} & {
[x: PropertyKey]: PropertyDescriptor;
Expand Down
10 changes: 4 additions & 6 deletions generated/lib.es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,16 @@ interface ObjectConstructor {
* Returns the prototype of an object.
* @param o The object that references the prototype.
*/
getPrototypeOf<T>(o: CheckNonNullable<T>): unknown;
getPrototypeOf(o: {}): unknown;

/**
* Gets the own property descriptor of the specified object.
* An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
* @param o Object that contains the property.
* @param p Name of the property.
*/
getOwnPropertyDescriptor<T>(
o: CheckNonNullable<T>,
getOwnPropertyDescriptor(
o: {},
p: PropertyKey
): PropertyDescriptor | undefined;

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

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

type CheckNonNullable<T> = [T] extends [null | undefined] ? never : T;

type JSONValue =
| null
| string
Expand Down
6 changes: 3 additions & 3 deletions lib/lib.es2015.core.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,16 @@ interface ObjectConstructor {
* @param target The target object to copy to.
* @param sources One or more source objects from which to copy properties
*/
assign<T, Ts extends readonly any[]>(
target: CheckNonNullable<T>,
assign<T extends {}, Ts extends readonly any[]>(
target: T,
...sources: Ts
): Intersect<[T, ...Ts]>;

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

/**
* Returns true if the values are the same value, false otherwise.
Expand Down
8 changes: 5 additions & 3 deletions lib/lib.es2017.object.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface ObjectConstructor {
* Returns an array of values of the enumerable properties of an object
* @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.
*/
values<T>(o: CheckNonNullable<T>): unknown[];
values(o: {}): unknown[];

/**
* Returns an array of key/values of the enumerable properties of an object
Expand All @@ -29,13 +29,15 @@ interface ObjectConstructor {
* Returns an array of key/values of the enumerable properties of an object
* @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.
*/
entries<T>(o: CheckNonNullable<T>): [string, unknown][];
entries(o: {}): [string, unknown][];

/**
* Returns an object containing all own property descriptors of an object
* @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.
*/
getOwnPropertyDescriptors<T>(o: CheckNonNullable<T>): {
getOwnPropertyDescriptors<T extends {}>(
o: T
): {
[P in keyof T]: TypedPropertyDescriptor<T[P]>;
} & {
[x: PropertyKey]: PropertyDescriptor;
Expand Down
10 changes: 4 additions & 6 deletions lib/lib.es5.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ type Intersect<T extends readonly any[]> = ((
? S
: never;

type CheckNonNullable<T> = [T] extends [null | undefined] ? never : T;

/**
* Evaluates JavaScript code and executes it.
* @param x A String value that contains valid JavaScript code.
Expand Down Expand Up @@ -49,16 +47,16 @@ interface ObjectConstructor {
* Returns the prototype of an object.
* @param o The object that references the prototype.
*/
getPrototypeOf<T>(o: CheckNonNullable<T>): unknown;
getPrototypeOf(o: {}): unknown;

/**
* Gets the own property descriptor of the specified object.
* An own property descriptor is one that is defined directly on the object and is not inherited from the object's prototype.
* @param o Object that contains the property.
* @param p Name of the property.
*/
getOwnPropertyDescriptor<T>(
o: CheckNonNullable<T>,
getOwnPropertyDescriptor(
o: {},
p: PropertyKey
): PropertyDescriptor | undefined;

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

/**
* Creates an object that has the specified prototype or that has null prototype.
Expand Down
Loading