4 files changed +37
-0
lines changed Original file line number Diff line number Diff line change @@ -174,6 +174,9 @@ function generateRawType(ast: AST, options: Options): string {
174
174
case 'ARRAY' :
175
175
return ( ( ) => {
176
176
const type = generateType ( ast . params , options )
177
+ if ( ! type ) {
178
+ return 'never'
179
+ }
177
180
return type . endsWith ( '"' ) ? '(' + type + ')[]' : type + '[]'
178
181
} ) ( )
179
182
case 'BOOLEAN' :
@@ -289,6 +292,9 @@ function generateRawType(ast: AST, options: Options): string {
289
292
function generateSetOperation ( ast : TIntersection | TUnion , options : Options ) : string {
290
293
const members = ( ast as TUnion ) . params . map ( _ => generateType ( _ , options ) )
291
294
const separator = ast . type === 'UNION' ? '|' : '&'
295
+ if ( ! members . length ) {
296
+ return 'never'
297
+ }
292
298
return members . length === 1 ? members [ 0 ] : '(' + members . join ( ' ' + separator + ' ' ) + ')'
293
299
}
294
300
Original file line number Diff line number Diff line change @@ -947,6 +947,27 @@ Generated by [AVA](https://avajs.dev).
947
947
}␊
948
948
`
949
949
950
+ ## emptySet.js
951
+
952
+ > Expected output to match snapshot for e2e test: emptySet.js
953
+
954
+ `/* eslint-disable */␊
955
+ /**␊
956
+ * This file was automatically generated by json-schema-to-typescript.␊
957
+ * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,␊
958
+ * and run json-schema-to-typescript to regenerate this file.␊
959
+ */␊
960
+ ␊
961
+ export interface EmptySet {␊
962
+ a?: never;␊
963
+ b?: never;␊
964
+ c?: never;␊
965
+ d?: {␊
966
+ [k: string]: unknown;␊
967
+ };␊
968
+ }␊
969
+ `
970
+
950
971
## enum.2.js
951
972
952
973
> Expected output to match snapshot for e2e test: enum.2.js
Original file line number Diff line number Diff line change
1
+ export const input = {
2
+ type : 'object' ,
3
+ properties : {
4
+ a : { anyOf : [ ] } ,
5
+ b : { oneOf : [ ] } ,
6
+ c : { allOf : [ ] } ,
7
+ d : { multipleOf : [ ] } ,
8
+ } ,
9
+ additionalProperties : false ,
10
+ }
0 commit comments