Skip to content

Commit c0d9b37

Browse files
committed
set type name correctly for Closure Compiler types (jsdoc#226)
1 parent 589eb30 commit c0d9b37

File tree

2 files changed

+27
-5
lines changed

2 files changed

+27
-5
lines changed

rhino_modules/jsdoc/tag/type/closureCompilerType.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ function parseVariable(type) {
4949
*/
5050
exports.parse = function(tagInfo) {
5151
var optional = parseOptional(tagInfo.type),
52-
nullable = parseNullable(tagInfo.type),
53-
variable = parseVariable(tagInfo.type);
52+
nullable = parseNullable(optional.type),
53+
variable = parseVariable(nullable.type);
5454

5555
return {
5656
name: tagInfo.name,
57-
type: variable.type || nullable.type || optional.type,
57+
type: variable.type,
5858
text: tagInfo.text,
5959
optional: tagInfo.optional || optional.optional, // don't override if already true
6060
nullable: nullable.nullable,
Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,25 @@
1-
describe("jsdoc/tag/type/closureCompilerType", function() {
2-
//TODO
1+
/*global describe: true, expect: true, it: true */
2+
describe('jsdoc/tag/type/closureCompilerType', function() {
3+
// TODO: more tests
4+
5+
var type = require('jsdoc/tag/type/closureCompilerType');
6+
7+
it('should exist', function() {
8+
expect(type).toBeDefined();
9+
expect(typeof type).toEqual('object');
10+
});
11+
12+
it('should export a parse function', function() {
13+
expect(type.parse).toBeDefined();
14+
expect(typeof type.parse).toEqual('function');
15+
});
16+
17+
describe('parse', function() {
18+
it('should correctly parse types that are both optional and nullable', function() {
19+
var info = type.parse( {type: '?string='} );
20+
expect(info.type).toEqual('string');
21+
expect(info.optional).toEqual(true);
22+
expect(info.nullable).toEqual(true);
23+
});
24+
});
325
});

0 commit comments

Comments
 (0)