Skip to content

Commit 1f99f9c

Browse files
committed
Don't output empty properties, reduce diff noise
1 parent 03242f3 commit 1f99f9c

15 files changed

+33
-51
lines changed

Diff for: lib/infer/params.js

+13-7
Original file line numberDiff line numberDiff line change
@@ -297,15 +297,21 @@ function combineTags(inferredTag, explicitTag) {
297297
defaultValue = inferredTag.default;
298298
}
299299

300+
const hasProperties = (inferredTag.properties &&
301+
inferredTag.properties.length) ||
302+
(explicitTag.properties && explicitTag.properties.length);
303+
300304
return _.assign(
301305
explicitTag,
302-
{
303-
properties: mergeNodes(
304-
inferredTag.properties || [],
305-
explicitTag.properties || []
306-
),
307-
type
308-
},
306+
hasProperties
307+
? {
308+
properties: mergeNodes(
309+
inferredTag.properties || [],
310+
explicitTag.properties || []
311+
)
312+
}
313+
: {},
314+
{ type },
309315
defaultValue ? { default: defaultValue } : {}
310316
);
311317
}

Diff for: test/fixture/_multi-file-input.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@
167167
"type": {
168168
"type": "NameExpression",
169169
"name": "Number"
170-
},
171-
"properties": []
170+
}
172171
}
173172
],
174173
"properties": [],

Diff for: test/fixture/class.output.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,7 @@
329329
"type": {
330330
"type": "NameExpression",
331331
"name": "boolean"
332-
},
333-
"properties": []
332+
}
334333
}
335334
],
336335
"properties": [],

Diff for: test/fixture/es6-class.output.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,7 @@
295295
"type": {
296296
"type": "NameExpression",
297297
"name": "string"
298-
},
299-
"properties": []
298+
}
300299
}
301300
],
302301
"properties": [],

Diff for: test/fixture/es6.output.json

+3-6
Original file line numberDiff line numberDiff line change
@@ -463,8 +463,7 @@
463463
"name": "Number"
464464
}
465465
]
466-
},
467-
"properties": []
466+
}
468467
},
469468
{
470469
"title": "param",
@@ -1085,8 +1084,7 @@
10851084
"type": {
10861085
"type": "NameExpression",
10871086
"name": "number"
1088-
},
1089-
"properties": []
1087+
}
10901088
},
10911089
{
10921090
"title": "param",
@@ -1147,8 +1145,7 @@
11471145
"type": {
11481146
"type": "NameExpression",
11491147
"name": "number"
1150-
},
1151-
"properties": []
1148+
}
11521149
}
11531150
],
11541151
"properties": [],

Diff for: test/fixture/inline-link.output.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,7 @@
158158
"type": {
159159
"type": "NameExpression",
160160
"name": "number"
161-
},
162-
"properties": []
161+
}
163162
}
164163
],
165164
"properties": [],
@@ -582,8 +581,7 @@
582581
"type": {
583582
"type": "NameExpression",
584583
"name": "number"
585-
},
586-
"properties": []
584+
}
587585
}
588586
],
589587
"properties": [],

Diff for: test/fixture/lends.output.json

+2-4
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,7 @@
272272
"type": {
273273
"type": "NameExpression",
274274
"name": "string"
275-
},
276-
"properties": []
275+
}
277276
}
278277
],
279278
"properties": [],
@@ -524,8 +523,7 @@
524523
"type": {
525524
"type": "NameExpression",
526525
"name": "string"
527-
},
528-
"properties": []
526+
}
529527
}
530528
],
531529
"properties": [],

Diff for: test/fixture/literal_types.output.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,7 @@
9696
"value": 3.14
9797
}
9898
]
99-
},
100-
"properties": []
99+
}
101100
}
102101
],
103102
"properties": [],

Diff for: test/fixture/memberedclass.output.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,7 @@
268268
"type": {
269269
"type": "NameExpression",
270270
"name": "boolean"
271-
},
272-
"properties": []
271+
}
273272
}
274273
],
275274
"properties": [],

Diff for: test/fixture/merge-infered-type.output.json

-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@
183183
}
184184
}
185185
},
186-
"properties": [],
187186
"type": {
188187
"type": "NameExpression",
189188
"name": "number"

Diff for: test/fixture/multisignature.output.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,7 @@
335335
"type": {
336336
"type": "NameExpression",
337337
"name": "Date"
338-
},
339-
"properties": []
338+
}
340339
}
341340
],
342341
"properties": [],

Diff for: test/fixture/nest_params.output.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -339,8 +339,7 @@
339339
"name": "string"
340340
}
341341
},
342-
"default": "minion",
343-
"properties": []
342+
"default": "minion"
344343
}
345344
],
346345
"properties": [],

Diff for: test/fixture/params.output.json

+5-12
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,7 @@
154154
"type": {
155155
"type": "NameExpression",
156156
"name": "number"
157-
},
158-
"properties": []
157+
}
159158
},
160159
{
161160
"title": "param",
@@ -380,8 +379,7 @@
380379
"type": {
381380
"type": "NameExpression",
382381
"name": "String"
383-
},
384-
"properties": []
382+
}
385383
},
386384
{
387385
"title": "param",
@@ -515,7 +513,6 @@
515513
"name": "number"
516514
}
517515
},
518-
"properties": [],
519516
"default": "2"
520517
}
521518
],
@@ -782,8 +779,7 @@
782779
"type": {
783780
"type": "NameExpression",
784781
"name": "number"
785-
},
786-
"properties": []
782+
}
787783
}
788784
],
789785
"properties": [],
@@ -2223,7 +2219,6 @@
22232219
"name": "number"
22242220
}
22252221
},
2226-
"properties": [],
22272222
"default": "123"
22282223
}
22292224
],
@@ -2456,8 +2451,7 @@
24562451
"offset": 22
24572452
}
24582453
}
2459-
},
2460-
"properties": []
2454+
}
24612455
}
24622456
],
24632457
"properties": [],
@@ -2699,8 +2693,7 @@
26992693
"type": {
27002694
"type": "NameExpression",
27012695
"name": "any"
2702-
},
2703-
"properties": []
2696+
}
27042697
},
27052698
{
27062699
"title": "param",

Diff for: test/fixture/simple-two.output.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,7 @@
167167
"type": {
168168
"type": "NameExpression",
169169
"name": "Number"
170-
},
171-
"properties": []
170+
}
172171
}
173172
],
174173
"properties": [],

Diff for: test/lib/infer/params.js

-1
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,6 @@ test('inferParams', function(t) {
294294
name: 'x',
295295
title: 'param',
296296
lineNumber: 1,
297-
properties: [],
298297
type: {
299298
expression: {
300299
type: 'NameExpression',

0 commit comments

Comments
 (0)