Skip to content

Commit da57885

Browse files
committed
Format
1 parent fe8f3c3 commit da57885

16 files changed

Lines changed: 196 additions & 76 deletions

File tree

tasks.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ Task.run('publish', (otp: string, target: string = `target/build`) => PublishPac
6262
// ------------------------------------------------------------------
6363
// Format
6464
// ------------------------------------------------------------------
65-
Task.run('format', () => Task.shell('deno fmt src test/**/*.ts'))
65+
Task.run('format', () => Task.shell('deno fmt src test/typebox'))
6666
// ------------------------------------------------------------------
6767
// Syntax
6868
// ------------------------------------------------------------------

test/typebox/runtime/type/engine/action/keyof.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ Test('Should KeyOf 17', () => {
214214
])
215215
])
216216
const T: Type.TUnion<[
217-
Type.TLiteral<'x'>,
217+
Type.TLiteral<'x'>,
218218
Type.TLiteral<'y'>,
219219
Type.TLiteral<'z'>,
220220
Type.TLiteral<'w'>

test/typebox/runtime/type/script/indexed.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ Test('Should Indexed 8', () => {
5151
Assert.IsTrue(Type.IsNumber(T.anyOf[0]))
5252
Assert.IsTrue(Type.IsString(T.anyOf[1]))
5353
})
54-
Test('Should Indexed 9', () => {
54+
Test('Should Indexed 9', () => {
5555
const T: Type.TLiteral<1> = Type.Script('[[1], 2, 3][0][0]')
5656
Assert.IsTrue(Type.IsLiteral(T))
5757
Assert.IsEqual(T.const, 1)

test/typebox/runtime/type/script/~action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ Test('Should Action 13', () => {
7373
Assert.IsEqual(T.anyOf[0].const, 'x')
7474
Assert.IsEqual(T.anyOf[1].const, 'y')
7575
})
76-
Test('Should Action 14', () => {
76+
Test('Should Action 14', () => {
7777
const T: Type.TLiteral<'hello'> = Type.Script('Lowercase<"HELLO">')
7878
Assert.IsTrue(Type.IsLiteral(T))
7979
Assert.IsEqual(T.const, 'hello')

test/typebox/runtime/value/check/base.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ Test('Should validate Base 6', () => {
4949
return false
5050
}
5151
override Errors(): object[] {
52-
return [{
52+
return [{
5353
keyword: '~standard',
5454
schemaPath: '',
5555
instancePath: '',
5656
params: { issues: [{ message: '' }] },
5757
message: ''
58-
}]
58+
}]
5959
}
6060
}
6161
Fail(new Foo(), [])
@@ -66,13 +66,13 @@ Test('Should validate Base 7', () => {
6666
return false
6767
}
6868
override Errors(): object[] {
69-
return [{
69+
return [{
7070
keyword: '~standard',
7171
schemaPath: '',
7272
instancePath: '',
7373
params: { issues: [{ message: 1 }] },
7474
message: ''
75-
}]
75+
}]
7676
}
7777
}
7878
Fail(new Foo(), [])
@@ -83,13 +83,13 @@ Test('Should validate Base 8', () => {
8383
return false
8484
}
8585
override Errors(): object[] {
86-
return [{
86+
return [{
8787
keyword: '~standard',
8888
schemaPath: '',
8989
instancePath: '',
9090
params: { issues: null },
9191
message: ''
92-
}]
92+
}]
9393
}
9494
}
9595
Fail(new Foo(), [])
@@ -100,12 +100,12 @@ Test('Should validate Base 9', () => {
100100
return false
101101
}
102102
override Errors(): object[] {
103-
return [{
103+
return [{
104104
keyword: '~standard',
105105
schemaPath: '',
106106
instancePath: '',
107107
params: { issues: [{ message: '', path: [] }] }
108-
}]
108+
}]
109109
}
110110
}
111111
Fail(new Foo(), [])
@@ -156,4 +156,4 @@ Test('Should validate Base 13', () => {
156156
}
157157
}
158158
Fail(new Foo(), [])
159-
})
159+
})

test/typebox/runtime/value/clean/union.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,33 +146,32 @@ Test('Should Clean 17', () => {
146146
Test('Should Clean 18', () => {
147147
const T = Type.Union([
148148
Type.Object({ oneof_prop_a: Type.String() }),
149-
Type.Object({ oneof_prop_b: Type.Optional(Type.String()) }),
149+
Type.Object({ oneof_prop_b: Type.Optional(Type.String()) })
150150
])
151151
const A = Value.Clean(T, { oneof_prop_a: 'A' })
152152
Assert.IsEqual(A, { oneof_prop_a: 'A' })
153153
})
154154
Test('Should Clean 19', () => {
155155
const T = Type.Union([
156156
Type.Object({ oneof_prop_a: Type.String() }),
157-
Type.Object({ oneof_prop_b: Type.Optional(Type.String()) }),
157+
Type.Object({ oneof_prop_b: Type.Optional(Type.String()) })
158158
])
159159
const A = Value.Clean(T, { oneof_prop_b: 'B' })
160160
Assert.IsEqual(A, { oneof_prop_b: 'B' })
161161
})
162162
Test('Should Clean 20', () => {
163163
const T = Type.Union([
164164
Type.Object({ oneof_prop_a: Type.String() }),
165-
Type.Object({ oneof_prop_b: Type.Optional(Type.String()) }),
165+
Type.Object({ oneof_prop_b: Type.Optional(Type.String()) })
166166
])
167167
const A = Value.Clean(T, { oneof_prop_b: undefined })
168168
Assert.IsEqual(A, { oneof_prop_b: undefined })
169169
})
170170
Test('Should Clean 21', () => {
171171
const T = Type.Union([
172172
Type.Object({ oneof_prop_a: Type.String() }),
173-
Type.Object({ oneof_prop_b: Type.Optional(Type.String()) }),
173+
Type.Object({ oneof_prop_b: Type.Optional(Type.String()) })
174174
])
175-
const A = Value.Clean(T, { })
176-
Assert.IsEqual(A, { })
175+
const A = Value.Clean(T, {})
176+
Assert.IsEqual(A, {})
177177
})
178-

test/typebox/runtime/value/convert/object.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ Test('Should Convert 4', () => {
3636
// ------------------------------------------------------------------
3737
// IsOptionalUndefined
3838
//
39-
// https://github.com/sinclairzx81/typebox/issues/1336#issuecomment-3312808962
39+
// https://github.com/sinclairzx81/typebox/issues/1336#issuecomment-3312808962
4040
// ------------------------------------------------------------------
4141
Test('Should Convert 5', () => {
4242
const T = Type.Object({ x: Type.Optional(Type.Number()) })
@@ -52,4 +52,4 @@ Test('Should Convert 7', () => {
5252
const T = Type.Object({ x: Type.Optional(Type.Number()) })
5353
const R = Value.Convert(T, { x: undefined })
5454
Assert.IsEqual(R, { x: undefined })
55-
})
55+
})
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import { Assert } from 'test'
22
import { type XStatic } from 'typebox/schema'
33

4-
5-
64
// should infer as expando
75

86
type T = XStatic<{
@@ -11,4 +9,4 @@ type T = XStatic<{
119
}
1210
}>
1311

14-
Assert.IsExtendsMutual<T, { [x: string]: number; }>(true)
12+
Assert.IsExtendsMutual<T, { [x: string]: number }>(true)

test/typebox/static/type/cyclic.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
import { type Static, Type } from 'typebox'
32
import { Assert } from 'test'
43

@@ -15,9 +14,9 @@ import { Assert } from 'test'
1514
}, 'NonCyclic')
1615
type NonCyclic = Static<typeof NonCyclic>
1716
// Invariant
18-
Assert.IsExtendsMutual<{ x: 1, y: 2, z: false }, NonCyclic>(false)
17+
Assert.IsExtendsMutual<{ x: 1; y: 2; z: false }, NonCyclic>(false)
1918
// Extends
20-
Assert.IsExtendsMutual<{ x: number, y: number, z: number }, NonCyclic>(true)
19+
Assert.IsExtendsMutual<{ x: number; y: number; z: number }, NonCyclic>(true)
2120
}
2221

2322
// ------------------------------------------------------------------
@@ -35,7 +34,7 @@ import { Assert } from 'test'
3534
// Invariant
3635
Assert.IsExtends<{ deep: 1 }, Deep>(false)
3736
Assert.IsExtends<{ deep: { deep: { deep: 1 } } }, Deep>(false)
38-
37+
3938
// Extends
4039
Assert.IsExtends<{ deep: any }, Deep>(true)
4140
Assert.IsExtends<{ deep: { deep: { deep: any } } }, Deep>(true)
@@ -53,7 +52,7 @@ import { Assert } from 'test'
5352
Type.String(),
5453
Type.Number(),
5554
Type.Boolean(),
56-
Type.Null(),
55+
Type.Null()
5756
])
5857
}, 'JsonValue')
5958

test/typebox/static/type/enum.ts

Lines changed: 134 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ import { Assert } from 'test'
4444
// TypeScript Enum: Small
4545
// ------------------------------------------------------------------
4646
{
47-
enum E { A, B, C }
47+
enum E {
48+
A,
49+
B,
50+
C
51+
}
4852
const T = Type.Enum(E)
4953
type T = Static<typeof T>
5054
Assert.IsExtends<T, E>(true)
@@ -55,15 +59,135 @@ import { Assert } from 'test'
5559
// ------------------------------------------------------------------
5660
{
5761
enum E {
58-
A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, A11, A12, A13, A14, A15, A16,
59-
A17, A18, A19, A20, A21, A22, A23, A24, A25, A26, A27, A28, A29, A30, A31, A32,
60-
A33, A34, A35, A36, A37, A38, A39, A40, A41, A42, A43, A44, A45, A46, A47, A48,
61-
A49, A50, A51, A52, A53, A54, A55, A56, A57, A58, A59, A60, A61, A62, A63, A64,
62-
A65, A66, A67, A68, A69, A70, A71, A72, A73, A74, A75, A76, A77, A78, A79, A80,
63-
A81, A82, A83, A84, A85, A86, A87, A88, A89, A90, A91, A92, A93, A94, A95, A96,
64-
A97, A98, A99, A100, A101, A102, A103, A104, A105, A106, A107, A108, A109, A110, A111, A112,
65-
A113, A114, A115, A116, A117, A118, A119, A120, A121, A122, A123, A124, A125, A126, A127, A128
66-
};
62+
A1,
63+
A2,
64+
A3,
65+
A4,
66+
A5,
67+
A6,
68+
A7,
69+
A8,
70+
A9,
71+
A10,
72+
A11,
73+
A12,
74+
A13,
75+
A14,
76+
A15,
77+
A16,
78+
A17,
79+
A18,
80+
A19,
81+
A20,
82+
A21,
83+
A22,
84+
A23,
85+
A24,
86+
A25,
87+
A26,
88+
A27,
89+
A28,
90+
A29,
91+
A30,
92+
A31,
93+
A32,
94+
A33,
95+
A34,
96+
A35,
97+
A36,
98+
A37,
99+
A38,
100+
A39,
101+
A40,
102+
A41,
103+
A42,
104+
A43,
105+
A44,
106+
A45,
107+
A46,
108+
A47,
109+
A48,
110+
A49,
111+
A50,
112+
A51,
113+
A52,
114+
A53,
115+
A54,
116+
A55,
117+
A56,
118+
A57,
119+
A58,
120+
A59,
121+
A60,
122+
A61,
123+
A62,
124+
A63,
125+
A64,
126+
A65,
127+
A66,
128+
A67,
129+
A68,
130+
A69,
131+
A70,
132+
A71,
133+
A72,
134+
A73,
135+
A74,
136+
A75,
137+
A76,
138+
A77,
139+
A78,
140+
A79,
141+
A80,
142+
A81,
143+
A82,
144+
A83,
145+
A84,
146+
A85,
147+
A86,
148+
A87,
149+
A88,
150+
A89,
151+
A90,
152+
A91,
153+
A92,
154+
A93,
155+
A94,
156+
A95,
157+
A96,
158+
A97,
159+
A98,
160+
A99,
161+
A100,
162+
A101,
163+
A102,
164+
A103,
165+
A104,
166+
A105,
167+
A106,
168+
A107,
169+
A108,
170+
A109,
171+
A110,
172+
A111,
173+
A112,
174+
A113,
175+
A114,
176+
A115,
177+
A116,
178+
A117,
179+
A118,
180+
A119,
181+
A120,
182+
A121,
183+
A122,
184+
A123,
185+
A124,
186+
A125,
187+
A126,
188+
A127,
189+
A128
190+
}
67191
const T = Type.Enum(E)
68192
type T = Static<typeof T>
69193
Assert.IsExtends<T, E>(true)

0 commit comments

Comments
 (0)