Skip to content

Commit

Permalink
fix(guess): null value and object expression using string key
Browse files Browse the repository at this point in the history
  • Loading branch information
h13i32maru committed Dec 31, 2016
1 parent d943e5e commit 5920c1f
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Parser/ParamParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]};
}
Expand All @@ -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] = '*';
}
}

Expand Down

0 comments on commit 5920c1f

Please sign in to comment.