Revision 0.28.1 (#397)

This commit is contained in:
sinclairzx81
2023-04-21 08:20:07 +09:00
committed by GitHub
parent 8f37557926
commit a8f4f180bc
5 changed files with 34 additions and 4 deletions
+1
View File
@@ -10,6 +10,7 @@ import './emum'
import './extract'
import './exclude'
import './function'
import './indexed'
import './instance-type'
import './intersect'
import './keyof'
+29
View File
@@ -0,0 +1,29 @@
import { Expect } from './assert'
import { Type, Static } from '@sinclair/typebox'
{
const T = Type.Object({
x: Type.Number(),
y: Type.String(),
})
const I = Type.Index(T, ['x', 'y'])
Expect(I).ToInfer<number | string>()
}
{
const T = Type.Tuple([Type.Number(), Type.String(), Type.Boolean()])
const I = Type.Index(T, Type.Union([Type.Literal('0'), Type.Literal('1')]))
Expect(I).ToInfer<number | string>()
}
{
const T = Type.Tuple([Type.Number(), Type.String(), Type.Boolean()])
const I = Type.Index(T, Type.Union([Type.Literal(0), Type.Literal(1)]))
Expect(I).ToInfer<number | string>()
}
{
const T = Type.Object({
ab: Type.Number(),
ac: Type.String(),
})
const I = Type.Index(T, Type.TemplateLiteral([Type.Literal('a'), Type.Union([Type.Literal('b'), Type.Literal('c')])]))
Expect(I).ToInfer<number | string>()
}