Skip to content
This repository has been archived by the owner on Mar 27, 2021. It is now read-only.

Commit

Permalink
fix: added an objectkey type to allow for all key types in the adtmem…
Browse files Browse the repository at this point in the history
…ber type
  • Loading branch information
BlueGhostAlt committed Sep 19, 2020
1 parent a1400c4 commit afbbd01
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { EndoTask, filter, pack, Task } from "@kirrus/core"

type ADTBase<T = string> = { _type: T }
type ObjectKey = number | string | symbol

/**
* A helper type for extracting the members of an ADT
*/
export type ADTMember<ADT, Type extends string> = Extract<
export type ADTMember<
ADT,
{ _type: Type }
>
Type extends ObjectKey
> = Extract<ADT, { _type: Type }>

/**
* A helper that takes an object whose keys will be matched
Expand Down Expand Up @@ -96,7 +97,7 @@ export const packMatched = <A extends ADTBase>(
* @returns An object made up of the passed keys and their
* generated helpers
*/
export const generateMatchers = <T extends string>(
export const generateMatchers = <T extends ObjectKey>(
keys: T[]
) => <A extends ADTBase<T>>() =>
(Object.fromEntries(
Expand Down

0 comments on commit afbbd01

Please sign in to comment.