File tree Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Expand file tree Collapse file tree 2 files changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -166,12 +166,23 @@ describe('types', () => {
166166 } ) ;
167167 } ) ;
168168
169- test ( 'options' , ( ) => {
170- types . number ( {
169+ test ( 'options, range and modulo ' , ( ) => {
170+ const options = {
171171 maximum : 9 ,
172172 minimum : 2 ,
173173 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 ) ;
175186
176187 // @ts -expect-error invalid option
177188 types . number ( { maxLength : 1 } ) ;
@@ -327,11 +338,12 @@ describe('types', () => {
327338 } ) ;
328339
329340 test ( 'options' , ( ) => {
330- types . string ( {
341+ const options = {
331342 enum : [ 'foo' , 'bar' ] ,
332343 maxLength : 9 ,
333344 minLength : 1 ,
334- } ) ;
345+ } as const ;
346+ types . string ( options ) ;
335347
336348 // @ts -expect-error invalid option
337349 types . string ( { maximum : 1 } ) ;
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ interface ArrayOptions extends GenericOptions {
1818}
1919
2020interface NumberOptions extends GenericOptions {
21- enum ?: number [ ] ;
21+ enum ?: readonly number [ ] ;
2222 exclusiveMaximum ?: boolean ;
2323 exclusiveMinimum ?: boolean ;
2424 maximum ?: number ;
@@ -35,7 +35,7 @@ interface ObjectOptions extends GenericOptions {
3535}
3636
3737interface StringOptions extends GenericOptions {
38- enum ?: string [ ] ;
38+ enum ?: readonly string [ ] ;
3939 maxLength ?: number ;
4040 minLength ?: number ;
4141 pattern ?: string ;
You can’t perform that action at this time.
0 commit comments