Skip to content

Commit

Permalink
Reimplement Index Types
Browse files Browse the repository at this point in the history
  • Loading branch information
sinclairzx81 committed Nov 22, 2023
1 parent c0d2a1d commit 3b5b5ee
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { Value, ValuePointer } from '@sinclair/typebox/value'
import { Type, TypeGuard, Kind, Static, TSchema, TProperties, TArray, TLiteral, TTemplateLiteral } from '@sinclair/typebox'
import { TObject, TUnion, TInteger, TBigInt, TIntersect, TString, TNumber, TBoolean, TNever, TTuple, UnionType, TRecursive } from '@sinclair/typebox'

export type EmptyString = ''

// ------------------------------------------------------------------
// TemplateLiteralFinite
// ------------------------------------------------------------------
Expand Down Expand Up @@ -56,16 +58,13 @@ export type TTemplateLiteralConst<T, Acc extends string> =
T extends TBoolean ? `${boolean}` :
never
// prettier-ignore
export type TTemplateLiteralUnion<T extends TTemplateLiteralKind[], Acc extends string = ''> =
export type TTemplateLiteralUnion<T extends TTemplateLiteralKind[], Acc extends string = EmptyString> =
T extends [infer L, ...infer R] ? `${TTemplateLiteralConst<L, Acc>}${TTemplateLiteralUnion<Assert<R, TTemplateLiteralKind[]>, Acc>}` :
Acc

// export type TTemplateLiteralKind = TUnion | TLiteral | TInteger | TTemplateLiteral | TNumber | TBigInt | TString | TBoolean | TNever
// ------------------------------------------------------------------
// TIndexer
// ------------------------------------------------------------------
export type EmptyString = ''

// prettier-ignore
export type TIndexerUnion<T extends TSchema[]> =
T extends [infer L extends TSchema, ...infer R extends TSchema[]]
Expand Down

0 comments on commit 3b5b5ee

Please sign in to comment.