Skip to content

Commit 2d0bd0e

Browse files
szymntmcw
authored andcommitted
fix: inferred properties duplicating explicitly specified ones
1 parent 44e36c9 commit 2d0bd0e

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

__tests__/lib/infer/properties.js

+14
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,20 @@ test('inferProperties', function() {
2929
}
3030
]);
3131

32+
expect(
33+
evaluate('/** @property {number} b */ type a = { b: 1 };').properties
34+
).toEqual([
35+
{
36+
lineNumber: 0,
37+
name: 'b',
38+
title: 'property',
39+
type: {
40+
name: 'number',
41+
type: 'NameExpression'
42+
}
43+
}
44+
]);
45+
3246
expect(
3347
evaluate('/** */interface a { b: 1, c: { d: 2 } };').properties
3448
).toEqual([

src/infer/properties.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function inferProperties(comment) {
3535
const explicitProperties = new Set();
3636
// Ensure that explicitly specified properties are not overridden
3737
// by inferred properties
38-
comment.properties.forEach(prop => explicitProperties.add(prop));
38+
comment.properties.forEach(prop => explicitProperties.add(prop.name));
3939

4040
function inferProperties(value, prefix) {
4141
if (value.type === 'ObjectTypeAnnotation') {

0 commit comments

Comments
 (0)