Skip to content
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

Object.keys/values/entries type definitions should be improved #76

Closed
Validark opened this issue May 27, 2019 · 0 comments
Closed

Object.keys/values/entries type definitions should be improved #76

Validark opened this issue May 27, 2019 · 0 comments

Comments

@Validark
Copy link
Contributor

Currently, the Object.keys/values/entries functions don't have the best types for our purposes. I wrote this up and thought we could use something similar to this in es.d.ts once #66 gets merged.

declare function keys<T>(o: Array<T>): Array<number>;
declare function keys<T>(o: Set<T>): Array<T>;
declare function keys<K, V>(o: Map<K, V>): Array<K>;
declare function keys<T>(o: T): Array<keyof T>;

declare function values<T>(o: Array<T>): Array<T>;
declare function values<T>(o: Set<T>): Array<true>;
declare function values<K, V>(o: Map<K, V>): Array<V>;
declare function values<T>(o: T): Array<T[keyof T]>;

declare function entries<T>(o: Array<T>): Array<[number, T]>;
declare function entries<T>(o: Set<T>): Array<[T, true]>;
declare function entries<K, V>(o: Map<K, V>): Array<[K, V]>;
declare function entries<T>(o: T): Array<[keyof T, T[keyof T]]>;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant