use the correct type expression for type applications that contain type unions (#714)

This commit is contained in:
Jeff Williams 2014-07-26 14:16:25 -07:00
parent b5653b838c
commit c557cd0a8b
2 changed files with 8 additions and 1 deletions

View File

@ -196,7 +196,7 @@ function getTypeStrings(parsedType, isOutermostType) {
// if this is the outermost type, we strip the modifiers; otherwise, we keep them // if this is the outermost type, we strip the modifiers; otherwise, we keep them
if (isOutermostType) { if (isOutermostType) {
applications = parsedType.applications.map(function(application) { applications = parsedType.applications.map(function(application) {
return getTypeStrings(application); return catharsis.stringify(application);
}).join(', '); }).join(', ');
typeString = util.format( '%s.<%s>', getTypeStrings(parsedType.expression), typeString = util.format( '%s.<%s>', getTypeStrings(parsedType.expression),
applications ); applications );

View File

@ -243,6 +243,13 @@ describe('jsdoc/tag/type', function() {
expect(info.type).toEqual( ['string'] ); expect(info.type).toEqual( ['string'] );
expect(info.variable).toBe(true); expect(info.variable).toBe(true);
}); });
it('should set the type correctly for type applications that contain type unions',
function() {
var desc = '{Array.<(string|number)>} foo - Foo.';
var info = jsdoc.tag.type.parse(desc, true, true);
expect(info.type).toEqual(['Array.<(string|number)>']);
});
}); });
}); });
}); });