Skip to content

Commit 009f33d

Browse files
mitermayernot-an-aardvark
authored andcommitted
Fix: Making sure union type stringification respects compact flag (eslint#199)
1 parent 19da935 commit 009f33d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

Diff for: lib/typed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@
11331133
for (i = 0, iz = node.elements.length; i < iz; ++i) {
11341134
result += stringifyImpl(node.elements[i], compact);
11351135
if ((i + 1) !== iz) {
1136-
result += '|';
1136+
result += compact ? '|' : ' | ';
11371137
}
11381138
}
11391139

Diff for: test/stringify.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ describe('Expression', function () {
237237
type: doctrine.Syntax.NameExpression,
238238
name: 'Number'
239239
}]
240-
}).should.equal('(String|Number)');
240+
}, {compact: false }).should.equal('(String | Number)');
241241

242242
doctrine.type.stringify({
243243
type: doctrine.Syntax.UnionType,
@@ -248,7 +248,7 @@ describe('Expression', function () {
248248
type: doctrine.Syntax.NameExpression,
249249
name: 'Number'
250250
}]
251-
}, { topLevel: true }).should.equal('String|Number');
251+
}, { topLevel: true, compact: true }).should.equal('String|Number');
252252
});
253253

254254
it('RestType', function () {
@@ -382,7 +382,7 @@ describe('Complex identity', function () {
382382
doctrine.type.parseType(data07)
383383
).should.equal(data07);
384384

385-
var data08 = 'function (new: Date, a: Array.<String, Number>, b: (Number|String|Date)): HashMap.<String, Number>';
385+
var data08 = 'function (new: Date, a: Array.<String, Number>, b: (Number | String | Date)): HashMap.<String, Number>';
386386
doctrine.type.stringify(
387387
doctrine.type.parseType(data08)
388388
).should.equal(data08);

0 commit comments

Comments
 (0)