Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Commit

Permalink
Fix: Making sure union type stringification respects compact flag (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
mitermayer authored and not-an-aardvark committed Oct 28, 2017
1 parent 19da935 commit 009f33d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion lib/typed.js
Original file line number Diff line number Diff line change
Expand Up @@ -1133,7 +1133,7 @@
for (i = 0, iz = node.elements.length; i < iz; ++i) {
result += stringifyImpl(node.elements[i], compact);
if ((i + 1) !== iz) {
result += '|';
result += compact ? '|' : ' | ';
}
}

Expand Down
6 changes: 3 additions & 3 deletions test/stringify.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe('Expression', function () {
type: doctrine.Syntax.NameExpression,
name: 'Number'
}]
}).should.equal('(String|Number)');
}, {compact: false }).should.equal('(String | Number)');

doctrine.type.stringify({
type: doctrine.Syntax.UnionType,
Expand All @@ -248,7 +248,7 @@ describe('Expression', function () {
type: doctrine.Syntax.NameExpression,
name: 'Number'
}]
}, { topLevel: true }).should.equal('String|Number');
}, { topLevel: true, compact: true }).should.equal('String|Number');
});

it('RestType', function () {
Expand Down Expand Up @@ -382,7 +382,7 @@ describe('Complex identity', function () {
doctrine.type.parseType(data07)
).should.equal(data07);

var data08 = 'function (new: Date, a: Array.<String, Number>, b: (Number|String|Date)): HashMap.<String, Number>';
var data08 = 'function (new: Date, a: Array.<String, Number>, b: (Number | String | Date)): HashMap.<String, Number>';
doctrine.type.stringify(
doctrine.type.parseType(data08)
).should.equal(data08);
Expand Down

0 comments on commit 009f33d

Please sign in to comment.