sindresorhus / ts-extras

Essential utilities for TypeScript projects
MIT License
587 stars 15 forks source link

Proposal: Export retyped builtins rather than wrappers #54

Closed Thom1729 closed 2 years ago

Thom1729 commented 2 years ago

E.g. instead of:

export function objectKeys<Type extends object>(value: Type): Array<ObjectKeys<Type>> {
    return Object.keys(value) as Array<ObjectKeys<Type>>;
}

Do:

export const objectKeys = Object.keys as <Type extends object>(value: Type) => Array<ObjectKeys<Type>>;

This saves a function call.