File tree 2 files changed +19
-7
lines changed
2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -166,12 +166,23 @@ describe('types', () => {
166
166
} ) ;
167
167
} ) ;
168
168
169
- test ( 'options' , ( ) => {
170
- types . number ( {
169
+ test ( 'options, range and modulo ' , ( ) => {
170
+ const options = {
171
171
maximum : 9 ,
172
172
minimum : 2 ,
173
173
multipleOf : 2 ,
174
- } ) ;
174
+ } as const ;
175
+ types . number ( options ) ;
176
+
177
+ // @ts -expect-error invalid option
178
+ types . number ( { maxLength : 1 } ) ;
179
+ } ) ;
180
+
181
+ test ( 'options, enum' , ( ) => {
182
+ const options = {
183
+ enum : [ 1 , 2 , 3 ] ,
184
+ } as const ;
185
+ types . number ( options ) ;
175
186
176
187
// @ts -expect-error invalid option
177
188
types . number ( { maxLength : 1 } ) ;
@@ -327,11 +338,12 @@ describe('types', () => {
327
338
} ) ;
328
339
329
340
test ( 'options' , ( ) => {
330
- types . string ( {
341
+ const options = {
331
342
enum : [ 'foo' , 'bar' ] ,
332
343
maxLength : 9 ,
333
344
minLength : 1 ,
334
- } ) ;
345
+ } as const ;
346
+ types . string ( options ) ;
335
347
336
348
// @ts -expect-error invalid option
337
349
types . string ( { maximum : 1 } ) ;
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ interface ArrayOptions extends GenericOptions {
18
18
}
19
19
20
20
interface NumberOptions extends GenericOptions {
21
- enum ?: number [ ] ;
21
+ enum ?: readonly number [ ] ;
22
22
exclusiveMaximum ?: boolean ;
23
23
exclusiveMinimum ?: boolean ;
24
24
maximum ?: number ;
@@ -35,7 +35,7 @@ interface ObjectOptions extends GenericOptions {
35
35
}
36
36
37
37
interface StringOptions extends GenericOptions {
38
- enum ?: string [ ] ;
38
+ enum ?: readonly string [ ] ;
39
39
maxLength ?: number ;
40
40
minLength ?: number ;
41
41
pattern ?: string ;
You can’t perform that action at this time.
0 commit comments