Skip to content

Commit

Permalink
feat(typing): add RecordValue<T>
Browse files Browse the repository at this point in the history
  • Loading branch information
lowlighter committed Jul 1, 2024
1 parent 5e6ab3e commit 8923194
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions typing/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ export type callback = Function
/** Record. */
export type record<T = unknown> = Record<PropertyKey, T>

/** Extract value type from Record. */
export type RecordValue<T> = T extends Record<PropertyKey, infer U> ? U : never

/** Extract key type from {@link https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Map | Map}. */
export type MapKey<T> = T extends Map<infer U, unknown> ? U : never

Expand Down

0 comments on commit 8923194

Please sign in to comment.