Skip to content

Commit b205f7d

Browse files
committed
use alternate array syntax
1 parent 253825e commit b205f7d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/utils.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,18 @@ const typify = (type) => {
3939

4040
if (typeof type === 'object') {
4141
let newType = type.typeName || type.type || 'any'
42-
if (newType.toLowerCase() === 'string' && type.possibleValues) {
43-
newType = `(${type.possibleValues.map(value => `'${value.value}'`).join(' | ')})`
44-
}
45-
if (type.collection) {
46-
type = newType + '[]'
42+
43+
if (newType.toLowerCase() === 'string' && type.possibleValues && type.collection) {
44+
// Array<foo | bar> syntax instead of (foo | bar)[]
45+
newType = `Array<${type.possibleValues.map(value => `'${value.value}'`).join(' | ')}>`
4746
} else {
48-
type = newType
47+
if (newType.toLowerCase() === 'string' && type.possibleValues) {
48+
newType = `(${type.possibleValues.map(value => `'${value.value}'`).join(' | ')})`
49+
}
50+
if (type.collection) newType += '[]'
4951
}
52+
53+
type = newType
5054
}
5155

5256
switch (type.toLowerCase()) {

0 commit comments

Comments
 (0)