This repository was archived by the owner on Jan 2, 2024. It is now read-only.
Commit b7c6467 1 parent 37d5840 commit b7c6467 Copy full SHA for b7c6467
File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -48,6 +48,7 @@ Currently supports:
48
48
* ` t.void `
49
49
* ` t.unknown `
50
50
* ` t.Int `
51
+ * ` t.literal `
51
52
52
53
## Use Cases
53
54
Original file line number Diff line number Diff line change @@ -115,6 +115,16 @@ export function fuzzUnknown(n: number): unknown {
115
115
return n ;
116
116
}
117
117
118
+ export function fuzzLiteral (
119
+ b : t . LiteralType < string | number | boolean >
120
+ ) : ConcreteFuzzer < unknown > {
121
+ return {
122
+ func : n => {
123
+ return b . value ;
124
+ } ,
125
+ } ;
126
+ }
127
+
118
128
export function fuzzUnion ( b : t . UnionType < t . Mixed [ ] > ) : ConcreteFuzzer < unknown > {
119
129
return {
120
130
children : b . types ,
@@ -206,4 +216,5 @@ export const coreFuzzers = [
206
216
gen ( fuzzPartial , 'PartialType' ) ,
207
217
gen ( fuzzArray , 'ArrayType' ) ,
208
218
gen ( fuzzIntersection , 'IntersectionType' ) ,
219
+ gen ( fuzzLiteral , 'LiteralType' ) ,
209
220
] ;
Original file line number Diff line number Diff line change @@ -15,7 +15,12 @@ export const types = [
15
15
t . unknown ,
16
16
t . array ( t . string ) ,
17
17
t . Int ,
18
-
18
+ t . literal ( 'hello' ) ,
19
+ t . literal ( 34.4 ) ,
20
+ t . literal ( true ) ,
21
+ t . literal ( '' ) ,
22
+ t . literal ( 0 ) ,
23
+ t . literal ( false ) ,
19
24
// Complex types
20
25
t . type ( { s : t . string , m : t . type ( { n : t . Int } ) } ) ,
21
26
t . type ( {
You can’t perform that action at this time.
0 commit comments