mirror of
https://github.com/zoriya/typebox.git
synced 2026-05-30 09:50:21 +00:00
@@ -1,56 +0,0 @@
|
||||
import { Expect } from './assert'
|
||||
import { Type, TRef, TObject, TNumber } from '@sinclair/typebox'
|
||||
|
||||
// prettier-ignore
|
||||
const Vector: TObject<{
|
||||
x: TNumber;
|
||||
y: TNumber;
|
||||
}> = Type.Object({
|
||||
x: Type.Number(),
|
||||
y: Type.Number(),
|
||||
}, { $id: 'Vector' })
|
||||
|
||||
// prettier-ignore
|
||||
const VectorRef: TRef<TObject<{
|
||||
x: TNumber;
|
||||
y: TNumber;
|
||||
}>> = Type.Ref(Vector)
|
||||
|
||||
// prettier-ignore
|
||||
const Vertex: TObject<{
|
||||
position: TRef<TObject<{
|
||||
x: TNumber;
|
||||
y: TNumber;
|
||||
}>>;
|
||||
texcoord: TRef<TObject<{
|
||||
x: TNumber;
|
||||
y: TNumber;
|
||||
}>>;
|
||||
}> = Type.Object({
|
||||
position: VectorRef,
|
||||
texcoord: VectorRef,
|
||||
})
|
||||
|
||||
// prettier-ignore
|
||||
const VertexDeref: TObject<{
|
||||
position: TObject<{
|
||||
x: TNumber;
|
||||
y: TNumber;
|
||||
}>;
|
||||
texcoord: TObject<{
|
||||
x: TNumber;
|
||||
y: TNumber;
|
||||
}>;
|
||||
}> = Type.Deref(Vertex, [Vector])
|
||||
|
||||
// prettier-ignore
|
||||
Expect(VertexDeref).ToStatic<{
|
||||
position: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
texcoord: {
|
||||
x: number;
|
||||
y: number;
|
||||
};
|
||||
}>
|
||||
+2
-2
@@ -3,11 +3,11 @@ import { Type, Static } from '@sinclair/typebox'
|
||||
|
||||
{
|
||||
const T = Type.String({ $id: 'T' })
|
||||
const R = Type.Ref(T)
|
||||
const R = Type.Ref('T')
|
||||
|
||||
type T = Static<typeof T>
|
||||
type R = Static<typeof R>
|
||||
|
||||
Expect(T).ToStatic<string>()
|
||||
Expect(R).ToStatic<string>()
|
||||
Expect(R).ToStatic<unknown>()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user