Skip to content

Commit 5df1623

Browse files
fix: wrap multi-type in brackets to ensure scoping is correct
1 parent 66b3d45 commit 5df1623

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/utils.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ const typify = (type) => {
3333
}
3434

3535
if (Array.isArray(type)) {
36-
const arrayType = Array.from(new Set(type.map(t => typify(t)))).join(' | ')
36+
const arrayType = Array.from(new Set(type.map(t => `(${typify(t)})`))).join(' | ')
3737
if (originalType.collection) {
3838
return `Array<${arrayType}>`
3939
}

test/utils_spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ describe('utils', () => {
6767
})
6868

6969
it('should map an array of types through typify as well', () => {
70-
expect(utils.typify(['String', 'Float', 'Boolean'])).to.deep.equal('string | number | boolean')
70+
expect(utils.typify(['String', 'Float', 'Boolean'])).to.deep.equal('(string) | (number) | (boolean)')
7171
})
7272

7373
it('should map an array of types through typify as well and remove duplicates', () => {
74-
expect(utils.typify(['String', 'Float', 'Double'])).to.deep.equal('string | number')
74+
expect(utils.typify(['String', 'Float', 'Double'])).to.deep.equal('(string) | (number)')
7575
})
7676

7777
it('should map node objects to the correct type', () => {

0 commit comments

Comments
 (0)