Skip to content

Commit

Permalink
fix: inferred properties duplicating explicitly specified ones
Browse files Browse the repository at this point in the history
  • Loading branch information
szymn authored and tmcw committed Dec 21, 2018
1 parent 44e36c9 commit 2d0bd0e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
14 changes: 14 additions & 0 deletions __tests__/lib/infer/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,20 @@ test('inferProperties', function() {
}
]);

expect(
evaluate('/** @property {number} b */ type a = { b: 1 };').properties
).toEqual([
{
lineNumber: 0,
name: 'b',
title: 'property',
type: {
name: 'number',
type: 'NameExpression'
}
}
]);

expect(
evaluate('/** */interface a { b: 1, c: { d: 2 } };').properties
).toEqual([
Expand Down
2 changes: 1 addition & 1 deletion src/infer/properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function inferProperties(comment) {
const explicitProperties = new Set();
// Ensure that explicitly specified properties are not overridden
// by inferred properties
comment.properties.forEach(prop => explicitProperties.add(prop));
comment.properties.forEach(prop => explicitProperties.add(prop.name));

function inferProperties(value, prefix) {
if (value.type === 'ObjectTypeAnnotation') {
Expand Down

0 comments on commit 2d0bd0e

Please sign in to comment.