@@ -167,20 +167,20 @@ export function print (type: Type, indent = '', count = false): string {
167
167
if ( type . literal ) return `${ JSON . stringify ( type . literal . value ) } ${ comment ( type , count ) } `
168
168
if ( type . scalar ) return `${ type . scalar } ${ comment ( type , count ) } `
169
169
if ( type . array ) {
170
- if ( type . array . sum ) return `(${ print ( type . array , indent ) } )[]`
171
- return `${ print ( type . array , indent ) } []`
170
+ if ( type . array . sum ) return `(${ print ( type . array , indent , count ) } )[]`
171
+ return `${ print ( type . array , indent , count ) } []`
172
172
}
173
173
174
174
if ( type . sum ) {
175
175
return type . sum
176
- . map ( x => print ( x , indent ) )
176
+ . map ( x => print ( x , indent , count ) )
177
177
. sort ( )
178
178
. join ( ' | ' )
179
179
}
180
180
181
181
if ( type . record ) {
182
182
let output = `{`
183
- output += `\n${ indent + ' ' } [key: ${ print ( type . record . key ) } ]: ${ print ( type . record . value , indent + ' ' ) } `
183
+ output += `\n${ indent + ' ' } [key: ${ print ( type . record . key , '' , count ) } ]: ${ print ( type . record . value , indent + ' ' , count ) } `
184
184
return output + `\n${ indent } }`
185
185
}
186
186
@@ -189,7 +189,7 @@ export function print (type: Type, indent = '', count = false): string {
189
189
for ( const key of Object . keys ( type . object ) . sort ( ) ) {
190
190
const fkey = ( / [ ^ A - Z a - z 0 - 9 _ ] / . test ( key ) || ( / ^ [ 0 - 9 ] / . test ( key ) && / [ A - Z a - z _ ] / . test ( key ) ) || key === "" ) ? `"${ key } "` : key
191
191
const ftype = type . object [ key ]
192
- output += `\n${ indent + ' ' } ${ fkey } ${ ( key in ( type . maybe ?? { } ) ) ? '?' : '' } : ${ print ( ftype , indent + ' ' ) } `
192
+ output += `\n${ indent + ' ' } ${ fkey } ${ ( key in ( type . maybe ?? { } ) ) ? '?' : '' } : ${ print ( ftype , indent + ' ' , count ) } `
193
193
}
194
194
return output + `\n${ indent } }`
195
195
}
0 commit comments