Skip to content

Commit f9e9a1b

Browse files
committed
Accept generics for defineProperty
Both `Object.defineProperty()` and `Object.defineProperties()` return their first argument. Use a generic so that typings can be passed through.
1 parent 0383b5c commit f9e9a1b

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/lib/es5.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,14 @@ interface ObjectConstructor {
177177
* @param p The property name.
178178
* @param attributes Descriptor for the property. It can be for a data property or an accessor property.
179179
*/
180-
defineProperty(o: any, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): any;
180+
defineProperty<T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>): T;
181181

182182
/**
183183
* Adds one or more properties to an object, and/or modifies attributes of existing properties.
184184
* @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object.
185185
* @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property.
186186
*/
187-
defineProperties(o: any, properties: PropertyDescriptorMap & ThisType<any>): any;
187+
defineProperties<T>(o: T, properties: PropertyDescriptorMap & ThisType<any>): T;
188188

189189
/**
190190
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.

tests/lib/lib.d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,14 +178,14 @@ interface ObjectConstructor {
178178
* @param p The property name.
179179
* @param attributes Descriptor for the property. It can be for a data property or an accessor property.
180180
*/
181-
defineProperty(o: any, p: string, attributes: PropertyDescriptor): any;
181+
defineProperty<T>(o: T, p: string, attributes: PropertyDescriptor): T;
182182

183183
/**
184184
* Adds one or more properties to an object, and/or modifies attributes of existing properties.
185185
* @param o Object on which to add or modify the properties. This can be a native JavaScript object or a DOM object.
186186
* @param properties JavaScript object that contains one or more descriptor objects. Each descriptor object describes a data property or an accessor property.
187187
*/
188-
defineProperties(o: any, properties: PropertyDescriptorMap): any;
188+
defineProperties<T>(o: T, properties: PropertyDescriptorMap): T;
189189

190190
/**
191191
* Prevents the modification of attributes of existing properties, and prevents the addition of new properties.

0 commit comments

Comments
 (0)