Update react-docgen

This commit is contained in:
Felix Kling 2015-03-05 00:37:02 -08:00
parent b87ba87e47
commit c0b0111e3a
4 changed files with 34 additions and 2 deletions

View File

@ -180,4 +180,16 @@ describe('propDocblockHandler', function() {
}
});
});
it('does not error if propTypes cannot be found', function() {
var definition = parse([
'({',
' fooBar: 42',
'})',
].join('\n'));
expect(function() {
propDocblockHandler(documentation, definition);
}).not.toThrow();
});
});

View File

@ -188,4 +188,16 @@ describe('propTypeHandler', function() {
},
});
});
it('does not error if propTypes cannot be found', function() {
var definition = parse([
'({',
' fooBar: 42',
'})',
].join('\n'));
expect(function() {
propTypeHandler(documentation, definition);
}).not.toThrow();
});
});

View File

@ -22,7 +22,11 @@ var types = require('recast').types.namedTypes;
var resolveToValue = require('../utils/resolveToValue');
function propDocBlockHandler(documentation: Documentation, path: NodePath) {
var propTypesPath = resolveToValue(getPropertyValuePath(path, 'propTypes'));
var propTypesPath = getPropertyValuePath(path, 'propTypes');
if (!propTypesPath) {
return;
}
propTypesPath = resolveToValue(propTypesPath);
if (!propTypesPath || !types.ObjectExpression.check(propTypesPath.node)) {
return;
}

View File

@ -100,7 +100,11 @@ function amendPropTypes(documentation, path) {
}
function propTypeHandler(documentation: Documentation, path: NodePath) {
var propTypesPath = resolveToValue(getPropertyValuePath(path, 'propTypes'));
var propTypesPath = getPropertyValuePath(path, 'propTypes');
if (!propTypesPath) {
return;
}
propTypesPath = resolveToValue(propTypesPath);
if (!propTypesPath || !types.ObjectExpression.check(propTypesPath.node)) {
return;
}