@@ -32,10 +32,10 @@ import * as T from '@sinclair/typebox'
32
32
//
33
33
// Dereference
34
34
//
35
- // Referential types pull from the Context or defer dereferencing
36
- // for later execution. This overlaps with module dereferencing,
37
- // where named identifiers in the syntax are deferred until
38
- // instantiation. This code should be revised as part of a
35
+ // Referential types pull from the Context or defer dereferencing
36
+ // for later execution. This overlaps with module dereferencing,
37
+ // where named identifiers in the syntax are deferred until
38
+ // instantiation. This code should be revised as part of a
39
39
// general-purpose Instantiate module (next revision)
40
40
//
41
41
// ------------------------------------------------------------------
@@ -55,8 +55,8 @@ const Dereference = (context: T.TProperties, key: string): T.TSchema => {
55
55
// Delimited sequences use an accumulated buffer to parse sequence
56
56
// tokens. This approach is more scalable than using a Union + Tuple
57
57
// + Epsilon pattern, as TypeScript can instantiate deeper when
58
- // tail-call recursive accumulators are employed. However, this
59
- // comes with a latent processing cost due to the need to decode
58
+ // tail-call recursive accumulators are employed. However, this
59
+ // comes with a latent processing cost due to the need to decode
60
60
// the accumulated buffer.
61
61
//
62
62
// - Encoding: [[<Ident>, ','][], [<Ident>] | []]
@@ -182,7 +182,7 @@ export type TKeywordBooleanMapping<Input extends 'boolean', Context extends T.TP
182
182
= T . TBoolean
183
183
// prettier-ignore
184
184
export function KeywordBooleanMapping ( input : 'boolean' , context : unknown ) {
185
- return Boolean ( )
185
+ return T . Boolean ( )
186
186
}
187
187
// -------------------------------------------------------------------
188
188
// KeywordUndefined: 'undefined'
@@ -288,8 +288,8 @@ export function KeywordMapping(input: unknown, context: unknown) {
288
288
// LiteralString: <String>
289
289
// -------------------------------------------------------------------
290
290
// prettier-ignore
291
- export type TLiteralStringMapping < Input extends string , Context extends T . TProperties >
292
- = T . TLiteral < Input >
291
+ export type TLiteralStringMapping < Input extends string , Context extends T . TProperties > =
292
+ Input extends T . TLiteralValue ? T . TLiteral < Input > : never
293
293
// prettier-ignore
294
294
export function LiteralStringMapping ( input : string , context : unknown ) {
295
295
return T . Literal ( input )
@@ -308,8 +308,8 @@ export function LiteralNumberMapping(input: string, context: unknown) {
308
308
// LiteralBoolean: 'true' | 'false'
309
309
// -------------------------------------------------------------------
310
310
// prettier-ignore
311
- export type TLiteralBooleanMapping < Input extends 'true' | 'false' , Context extends T . TProperties >
312
- = T . TLiteral < Input extends 'true' ? true : false >
311
+ export type TLiteralBooleanMapping < Input extends 'true' | 'false' , Context extends T . TProperties >
312
+ = Input extends 'true' ? T . TLiteral < true > : T . TLiteral < false >
313
313
// prettier-ignore
314
314
export function LiteralBooleanMapping ( input : 'true' | 'false' , context : unknown ) {
315
315
return T . Literal ( input === 'true' )
@@ -440,10 +440,10 @@ export function FactorMapping(input: [unknown, unknown, unknown, unknown], conte
440
440
//
441
441
// ExprBinaryMapping
442
442
//
443
- // TypeBox Union and Intersection types are flattened to prevent
444
- // excessive nesting of `anyOf` and `allOf`, ensuring a more
445
- // readable and presentable type for the user. This function
446
- // recursively reduces Union and Intersection types based on
443
+ // TypeBox Union and Intersection types are flattened to prevent
444
+ // excessive nesting of `anyOf` and `allOf`, ensuring a more
445
+ // readable and presentable type for the user. This function
446
+ // recursively reduces Union and Intersection types based on
447
447
// binary expressions parsed from input.
448
448
//
449
449
// ------------------------------------------------------------------
@@ -791,7 +791,7 @@ export function ArrayMapping(input: [unknown, unknown, unknown, unknown], contex
791
791
// prettier-ignore
792
792
export type TRecordMapping < Input extends [ unknown , unknown , unknown , unknown , unknown , unknown ] , Context extends T . TProperties >
793
793
= Input extends [ 'Record' , '<' , infer Key extends T . TSchema , ',' , infer Type extends T . TSchema , '>' ]
794
- ? T . TRecord < Key , Type >
794
+ ? T . TRecordOrObject < Key , Type >
795
795
: never
796
796
// prettier-ignore
797
797
export function RecordMapping ( input : [ unknown , unknown , unknown , unknown , unknown , unknown ] , context : unknown ) {
@@ -1022,9 +1022,9 @@ export type TReferenceMapping<Input extends string, Context extends T.TPropertie
1022
1022
? Input extends string
1023
1023
? TDereference < Context , Input >
1024
1024
: never
1025
- : never
1025
+ : never
1026
1026
// prettier-ignore
1027
1027
export function ReferenceMapping ( input : string , context : unknown ) {
1028
1028
const target = Dereference ( context as T . TProperties , input )
1029
1029
return target
1030
- }
1030
+ }
0 commit comments