From 2d0bd0e0f7d8227668e490584882292044c98795 Mon Sep 17 00:00:00 2001 From: Szymon Nowacki Date: Fri, 21 Dec 2018 11:53:39 +0100 Subject: [PATCH] fix: inferred properties duplicating explicitly specified ones --- __tests__/lib/infer/properties.js | 14 ++++++++++++++ src/infer/properties.js | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/__tests__/lib/infer/properties.js b/__tests__/lib/infer/properties.js index 0c468767c..cb4a98e57 100644 --- a/__tests__/lib/infer/properties.js +++ b/__tests__/lib/infer/properties.js @@ -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([ diff --git a/src/infer/properties.js b/src/infer/properties.js index 6a7f3f479..e7f609967 100644 --- a/src/infer/properties.js +++ b/src/infer/properties.js @@ -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') {