Skip to content

Commit 4fed4d5

Browse files
committed
Revision 0.9.0
1 parent d4fefdd commit 4fed4d5

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

example/typebox/compiled/mapping.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ import * as T from '@sinclair/typebox'
3232
//
3333
// Dereference
3434
//
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
3939
// general-purpose Instantiate module (next revision)
4040
//
4141
// ------------------------------------------------------------------
@@ -55,8 +55,8 @@ const Dereference = (context: T.TProperties, key: string): T.TSchema => {
5555
// Delimited sequences use an accumulated buffer to parse sequence
5656
// tokens. This approach is more scalable than using a Union + Tuple
5757
// + 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
6060
// the accumulated buffer.
6161
//
6262
// - Encoding: [[<Ident>, ','][], [<Ident>] | []]
@@ -182,7 +182,7 @@ export type TKeywordBooleanMapping<Input extends 'boolean', Context extends T.TP
182182
= T.TBoolean
183183
// prettier-ignore
184184
export function KeywordBooleanMapping(input: 'boolean', context: unknown) {
185-
return Boolean()
185+
return T.Boolean()
186186
}
187187
// -------------------------------------------------------------------
188188
// KeywordUndefined: 'undefined'
@@ -288,8 +288,8 @@ export function KeywordMapping(input: unknown, context: unknown) {
288288
// LiteralString: <String>
289289
// -------------------------------------------------------------------
290290
// 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
293293
// prettier-ignore
294294
export function LiteralStringMapping(input: string, context: unknown) {
295295
return T.Literal(input)
@@ -308,8 +308,8 @@ export function LiteralNumberMapping(input: string, context: unknown) {
308308
// LiteralBoolean: 'true' | 'false'
309309
// -------------------------------------------------------------------
310310
// 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>
313313
// prettier-ignore
314314
export function LiteralBooleanMapping(input: 'true' | 'false', context: unknown) {
315315
return T.Literal(input === 'true')
@@ -440,10 +440,10 @@ export function FactorMapping(input: [unknown, unknown, unknown, unknown], conte
440440
//
441441
// ExprBinaryMapping
442442
//
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
447447
// binary expressions parsed from input.
448448
//
449449
// ------------------------------------------------------------------
@@ -791,7 +791,7 @@ export function ArrayMapping(input: [unknown, unknown, unknown, unknown], contex
791791
// prettier-ignore
792792
export type TRecordMapping<Input extends [unknown, unknown, unknown, unknown, unknown, unknown], Context extends T.TProperties>
793793
= Input extends ['Record', '<', infer Key extends T.TSchema, ',', infer Type extends T.TSchema, '>']
794-
? T.TRecord<Key, Type>
794+
? T.TRecordOrObject<Key, Type>
795795
: never
796796
// prettier-ignore
797797
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
10221022
? Input extends string
10231023
? TDereference<Context, Input>
10241024
: never
1025-
: never
1025+
: never
10261026
// prettier-ignore
10271027
export function ReferenceMapping(input: string, context: unknown) {
10281028
const target = Dereference(context as T.TProperties, input)
10291029
return target
1030-
}
1030+
}

0 commit comments

Comments
 (0)