fix crash when a class property has no value (#1400)

This commit is contained in:
Jeff Williams 2017-07-12 19:03:46 -07:00
parent 5080ec75bc
commit a3523abebc
3 changed files with 14 additions and 1 deletions

View File

@ -492,7 +492,9 @@ walkers[Syntax.Property] = function(node, parent, state, cb) {
// move leading comments from key to property node
moveLeadingComments(node.key, node);
cb(node.value, node, state);
if (node.value) {
cb(node.value, node, state);
}
if (node.decorators) {
for (var i = 0, l = node.decorators.length; i < l; i++) {

View File

@ -5,4 +5,7 @@ class A {
/** Private property. */
#c = 2;
/** Property with no value assigned to it. */
d;
}

View File

@ -4,6 +4,7 @@ describe('class properties', function() {
var docSet = jasmine.getDocSetFromFile('test/fixtures/classproperties.js');
var b = docSet.getByLongname('A#b')[0];
var c = docSet.getByLongname('A#c')[0];
var d = docSet.getByLongname('A#d')[0];
it('should assign the correct name, memberof, and scope to class properties', function() {
expect(b.name).toBe('b');
@ -18,4 +19,11 @@ describe('class properties', function() {
expect(c.scope).toBe('instance');
expect(c.access).toBe('private');
});
it('should assign the correct name, memberof, and scope to class properties with no value ' +
'assigned', function() {
expect(d.name).toBe('d');
expect(d.memberof).toBe('A');
expect(d.scope).toBe('instance');
});
});