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 25, 2023
1 parent 90b2175 commit b095510
Show file tree
Hide file tree
Showing 4 changed files with 375 additions and 349 deletions.
11 changes: 6 additions & 5 deletions examples/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ import {
IsTemplateLiteralFiniteCheck,
UnionToTuple,
PatternNumber,
Increment,
AccessResolver,
Counter,
IndexAccessResolver,
IndexResolver,
Assert,
UnionToIntersect,
KeyResolver,
Ensure,
KeyOfResolver,
} from '@sinclair/typebox'

const A = Type.KeyOf(Type.Tuple([Type.Number()]))
console.log(A)
const R = KeyOfResolver.Resolve(Type.Union([Type.Object({ x: Type.Number(), y: Type.Number() }), Type.Object({ x: Type.Number(), z: Type.Number() })]))

const T = Type.Union([Type.Object({ x: Type.Number() }), Type.Object({ z: Type.Number() })])

const M = KeyResolver.Resolve(Type.Tuple([Type.Number(), Type.Number(), Type.Number()]))
const K = Type.KeyOf(T)
2 changes: 1 addition & 1 deletion examples/next/indexer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { TypeSystem } from '@sinclair/typebox/system'
import { TypeCompiler } from '@sinclair/typebox/compiler'
import { Value, ValuePointer } from '@sinclair/typebox/value'
import { Type, AccessResolver, TemplateLiteralParser, TemplateLiteralFinite, TemplateLiteralResolver, TypeGuard, TIntersect, TUnion, TTemplateLiteral, IsTemplateLiteralFiniteCheck, UnionToTuple, Static, TSchema, TLiteralValue, TLiteral, TNumber, TInteger, TBigInt, TString, PatternNumber } from '@sinclair/typebox'
import { Type, IndexAccessResolver, TemplateLiteralParser, TemplateLiteralFinite, TemplateLiteralResolver, TypeGuard, TIntersect, TUnion, TTemplateLiteral, IsTemplateLiteralFiniteCheck, UnionToTuple, Static, TSchema, TLiteralValue, TLiteral, TNumber, TInteger, TBigInt, TString, PatternNumber } from '@sinclair/typebox'
import { TObject } from '@sinclair/typebox'

const A = Type.Index(Type.Object({
Expand Down
Loading

0 comments on commit b095510

Please sign in to comment.