Skip to content

Commit

Permalink
🏷️ improve extends object instead of Object
Browse files Browse the repository at this point in the history
  • Loading branch information
VitorLuizC committed Jul 22, 2019
1 parent 63239a2 commit 0d99d33
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/**
* A collection of object keys.
*/
type PropertyKeys <T extends Object> = (PropertyKey & keyof T)[];
type PropertyKeys <T extends object> = (PropertyKey & keyof T)[];

/**
* A collection of object keys which match a type.
*/
type TypedPropertyKeys <T extends Object, U> = Extract<keyof T, U>[];
type TypedPropertyKeys <T extends object, U> = Extract<keyof T, U>[];

/**
* Get a collection of keys from an object.
* @param object
*/
const getKeys = <T extends Object> (object: T): PropertyKeys<T> => {
const getKeys = <T extends object> (object: T): PropertyKeys<T> => {
if (typeof Reflect === 'object' && typeof Reflect.ownKeys === 'function')
return Reflect.ownKeys(object) as PropertyKeys<T>;

Expand All @@ -38,7 +38,7 @@ export type PropertyDescriptors <T> = PropertyDescriptorMap & {
* Get an object with all object property descriptors.
* @param object
*/
const getDescriptors = <T extends Object> (object: T): PropertyDescriptors<T> => {
const getDescriptors = <T extends object> (object: T): PropertyDescriptors<T> => {
if (typeof Object.getOwnPropertyDescriptors === 'function')
return Object.getOwnPropertyDescriptors(object) as PropertyDescriptors<T>;

Expand Down

0 comments on commit 0d99d33

Please sign in to comment.