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 23, 2023
1 parent da79981 commit b76b135
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/typebox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export type Trim<T> = T extends `${' '}${infer U}` ? Trim<U> : T extends `${infe
export type Assert<T, E> = T extends E ? T : never
export type Evaluate<T> = T extends infer O ? { [K in keyof O]: O[K] } : never
export type Ensure<T> = T extends infer U ? U : never
export type EmptyString = ''
// --------------------------------------------------------------------------
// Type Asserts
// --------------------------------------------------------------------------
Expand Down Expand Up @@ -911,13 +912,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> =
T extends [infer L, ...infer R] ? `${TTemplateLiteralConst<L, Acc>}${TTemplateLiteralUnion<Assert<R, TTemplateLiteralKind[]>, Acc>}` :
Acc
export type TTemplateLiteralKeyRest<T extends TTemplateLiteral> = Assert<UnionToTuple<Static<T>>, TPropertyKey[]>
export interface TTemplateLiteral<T extends TTemplateLiteralKind[] = TTemplateLiteralKind[]> extends TSchema {
[Kind]: 'TemplateLiteral'
static: TTemplateLiteralUnion<T, ''>
static: TTemplateLiteralUnion<T, EmptyString>
type: 'string'
pattern: string // todo: it may be possible to infer this pattern
}
Expand Down

0 comments on commit b76b135

Please sign in to comment.