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 @@ -155,12 +155,23 @@ describe('types', () => {
155
155
expectType < typeof value > ( undefined ) ;
156
156
} ) ;
157
157
158
- test ( 'options' , ( ) => {
159
- types . number ( {
158
+ test ( 'options, range and modulo ' , ( ) => {
159
+ const options = {
160
160
maximum : 9 ,
161
161
minimum : 2 ,
162
162
multipleOf : 2 ,
163
- } ) ;
163
+ } as const ;
164
+ types . number ( options ) ;
165
+
166
+ // @ts -expect-error invalid option
167
+ types . number ( { maxLength : 1 } ) ;
168
+ } ) ;
169
+
170
+ test ( 'options, enum' , ( ) => {
171
+ const options = {
172
+ enum : [ 1 , 2 , 3 ] ,
173
+ } as const ;
174
+ types . number ( options ) ;
164
175
165
176
// @ts -expect-error invalid option
166
177
types . number ( { maxLength : 1 } ) ;
@@ -306,11 +317,12 @@ describe('types', () => {
306
317
} ) ;
307
318
308
319
test ( 'options' , ( ) => {
309
- types . string ( {
320
+ const options = {
310
321
enum : [ 'foo' , 'bar' ] ,
311
322
maxLength : 9 ,
312
323
minLength : 1 ,
313
- } ) ;
324
+ } as const ;
325
+ types . string ( options ) ;
314
326
315
327
// @ts -expect-error invalid option
316
328
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