Skip to content

Commit 5920c1f

Browse files
committed
fix(guess): null value and object expression using string key
1 parent d943e5e commit 5920c1f

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

src/Parser/ParamParser.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,10 @@ export default class ParamParser {
338338
return {types: ['string']};
339339
}
340340

341+
if (right.type === 'NullLiteral') {
342+
return {types: ['*']};
343+
}
344+
341345
if (right.type.includes('Literal')) {
342346
return {types: [typeof right.value]};
343347
}
@@ -353,15 +357,16 @@ export default class ParamParser {
353357
if (right.type === 'ObjectExpression') {
354358
const typeMap = {};
355359
for (const prop of right.properties) {
360+
const name = prop.key.name || prop.key.value;
356361
switch (prop.type) {
357362
case 'ObjectProperty':
358-
typeMap[prop.key.name] = typeof prop.value.value;
363+
typeMap[name] = prop.value.value ? typeof prop.value.value : '*';
359364
break;
360365
case 'ObjectMethod':
361-
typeMap[prop.key.name] = 'function';
366+
typeMap[name] = 'function';
362367
break;
363368
default:
364-
typeMap[prop.key.name] = '*';
369+
typeMap[name] = '*';
365370
}
366371
}
367372

0 commit comments

Comments
 (0)