Permalink
Browse files

fix(guess): null value and object expression using string key

  • Loading branch information...
h13i32maru committed Dec 31, 2016
1 parent d943e5e commit 5920c1f91633202ec795f360bb0ac12f68f258f2
Showing with 8 additions and 3 deletions.
  1. +8 −3 src/Parser/ParamParser.js
View
@@ -338,6 +338,10 @@ export default class ParamParser {
return {types: ['string']};
}
+ if (right.type === 'NullLiteral') {
+ return {types: ['*']};
+ }
+
if (right.type.includes('Literal')) {
return {types: [typeof right.value]};
}
@@ -353,15 +357,16 @@ export default class ParamParser {
if (right.type === 'ObjectExpression') {
const typeMap = {};
for (const prop of right.properties) {
+ const name = prop.key.name || prop.key.value;
switch (prop.type) {
case 'ObjectProperty':
- typeMap[prop.key.name] = typeof prop.value.value;
+ typeMap[name] = prop.value.value ? typeof prop.value.value : '*';
break;
case 'ObjectMethod':
- typeMap[prop.key.name] = 'function';
+ typeMap[name] = 'function';
break;
default:
- typeMap[prop.key.name] = '*';
+ typeMap[name] = '*';
}
}

0 comments on commit 5920c1f

Please sign in to comment.