diff --git a/src/type/module/module.ts b/src/type/module/module.ts index 3fef83c..255a338 100644 --- a/src/type/module/module.ts +++ b/src/type/module/module.ts @@ -26,7 +26,7 @@ THE SOFTWARE. ---------------------------------------------------------------------------*/ -import { Ensure } from '../helpers/index' +import { Assert, Ensure } from '../helpers/index' import { CreateType } from '../create/index' import { Kind } from '../symbols/index' import { SchemaOptions, TSchema } from '../schema/index' @@ -58,6 +58,7 @@ import { TUndefined } from '../undefined/index' import { TUnknown } from '../unknown/index' import { TVoid } from '../void/index' import { Static } from '../static/index' +import { TRecord } from '../record/index' // ------------------------------------------------------------------ // Infer @@ -75,6 +76,10 @@ type InferObject } & {} // prettier-ignore +type InferRecord = { + [_ in Assert, PropertyKey>]: Infer +} & {} +// prettier-ignore type InferConstructor = Ensure< new (...args: InferTuple) => Infer > @@ -116,6 +121,7 @@ type InferIterator = ( type Infer = ( Type extends TImport ? InferImport : Type extends TRef ? InferRef : + Type extends TRecord ? InferRecord : Type extends TObject ? InferObject : Type extends TConstructor ? InferConstructor : Type extends TFunction ? InferFunction : diff --git a/test/static/record.ts b/test/static/record.ts index ab18b06..8e25f9d 100644 --- a/test/static/record.ts +++ b/test/static/record.ts @@ -202,3 +202,12 @@ import { Type, Static } from '@sinclair/typebox' const T = Type.Record(K, Type.String()) Expect(T).ToStatic<{}>() } + +{ + const Module = Type.Module({ + T: Type.Record(Type.String(), Type.Ref('A')), + A: Type.String({ format: 'email' }), + }); + const T = Module.Import('T'); + Expect(T).ToStatic<{ [x: string]: string }>() +}