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 @@ -155,12 +155,23 @@ describe('types', () => {
155155 expectType < typeof value > ( undefined ) ;
156156 } ) ;
157157
158- test ( 'options' , ( ) => {
159- types . number ( {
158+ test ( 'options, range and modulo ' , ( ) => {
159+ const options = {
160160 maximum : 9 ,
161161 minimum : 2 ,
162162 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 ) ;
164175
165176 // @ts -expect-error invalid option
166177 types . number ( { maxLength : 1 } ) ;
@@ -306,11 +317,12 @@ describe('types', () => {
306317 } ) ;
307318
308319 test ( 'options' , ( ) => {
309- types . string ( {
320+ const options = {
310321 enum : [ 'foo' , 'bar' ] ,
311322 maxLength : 9 ,
312323 minLength : 1 ,
313- } ) ;
324+ } as const ;
325+ types . string ( options ) ;
314326
315327 // @ts -expect-error invalid option
316328 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