From 2bba92a0b137028511085905f99f4eda3487b420 Mon Sep 17 00:00:00 2001 From: sinclair Date: Fri, 3 Nov 2023 00:04:15 +0900 Subject: [PATCH] Ensure Record into Object for known Enum keys --- src/typebox.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/typebox.ts b/src/typebox.ts index 0f9d2e03c..9a4d248b7 100644 --- a/src/typebox.ts +++ b/src/typebox.ts @@ -650,7 +650,7 @@ export interface TPromise extends TSchema { export type TRecordFromUnionLiteralString = { [_ in K['const']]: T } export type TRecordFromUnionLiteralNumber = { [_ in K['const']]: T } // prettier-ignore -export type TRecordFromEnumKey = Ensure> +export type TRecordFromEnumKey, T extends TSchema> = Ensure> // prettier-ignore export type TRecordFromUnionRest = K extends [infer L, ...infer R] ? ( L extends TUnion ? TRecordFromUnionRest & TRecordFromUnionRest, T> : @@ -671,7 +671,7 @@ export type TRecordFromNumberKey = Ensure< export type TRecordFromIntegerKey = Ensure> // prettier-ignore export type TRecordResolve = - K extends TEnum ? TRecordFromEnumKey : // Enum before Union (intercept Hint) + K extends TEnum ? TRecordFromEnumKey : // Enum before Union (intercept Hint) K extends TUnion ? TRecordFromUnion : K extends TTemplateLiteral ? TRecordFromTemplateLiteralKey : K extends TLiteralString ? TRecordFromLiteralStringKey :