Skip to content

Commit 9b3d6da

Browse files
committed
fix count comments
1 parent 9a06985 commit 9b3d6da

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

lib.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -167,20 +167,20 @@ export function print (type: Type, indent = '', count = false): string {
167167
if (type.literal) return `${JSON.stringify(type.literal.value)}${comment(type, count)}`
168168
if (type.scalar) return `${type.scalar}${comment(type, count)}`
169169
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)}[]`
172172
}
173173

174174
if (type.sum) {
175175
return type.sum
176-
.map(x => print(x, indent))
176+
.map(x => print(x, indent, count))
177177
.sort()
178178
.join(' | ')
179179
}
180180

181181
if (type.record) {
182182
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)}`
184184
return output + `\n${indent}}`
185185
}
186186

@@ -189,7 +189,7 @@ export function print (type: Type, indent = '', count = false): string {
189189
for (const key of Object.keys(type.object).sort()) {
190190
const fkey = (/[^A-Za-z0-9_]/.test(key) || (/^[0-9]/.test(key) && /[A-Za-z_]/.test(key)) || key === "") ? `"${key}"` : key
191191
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)}`
193193
}
194194
return output + `\n${indent}}`
195195
}

0 commit comments

Comments
 (0)