diff --git a/src/interfaces/type.ts b/src/interfaces/type.ts index 9e6870d..9fb1163 100644 --- a/src/interfaces/type.ts +++ b/src/interfaces/type.ts @@ -13,6 +13,10 @@ * but that's OK, the generic parameter doesn't hurt in those cases. ****/ +type ValueIntersectionByKeyUnion = { + [P in TKey]: (k: T[P])=>void +} [TKey] extends ((k: infer I)=>void) ? I : never + export interface AssociatedTypes { undefined: { type: undefined @@ -24,10 +28,10 @@ export interface AssociatedTypes { } type AssociatedTypeNames = keyof AssociatedTypes['undefined'] -type ALookup = { +type ALookup = ValueIntersectionByKeyUnion<{ [K in keyof AssociatedTypes]: - T extends AssociatedTypes[K]['type'] ? AssociatedTypes[K][Name] : never -}[keyof AssociatedTypes] + T extends AssociatedTypes[K]['type'] ? AssociatedTypes[K][Name] : unknown}, + keyof AssociatedTypes> // For everything to compile, zero and one must be subtypes of T: export type ZeroType = ALookup & T diff --git a/src/numbers/type.ts b/src/numbers/type.ts index 11e5d1c..48fb95e 100644 --- a/src/numbers/type.ts +++ b/src/numbers/type.ts @@ -8,7 +8,7 @@ export const number_type = { declare module "../interfaces/type" { interface AssociatedTypes { - numbers: { + number: { type: number zero: 0 one: 1