Skip to content

Commit

Permalink
Use undefined instead of null as default value
Browse files Browse the repository at this point in the history
This fixes the type issues in mapbox#107. Also it makes more sense. I'm unsure about the `return undefined`.
  • Loading branch information
Timmmm authored Nov 6, 2019
1 parent b4eab64 commit 7b723c1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ function compileDest(ctx) {
for (var i = 0; i < ctx._proto.fields.length; i++) {
var field = ctx._proto.fields[i];
props[field.name + ': ' + JSON.stringify(ctx._defaults[field.name])] = true;
if (field.oneof) props[field.oneof + ': null'] = true;
if (field.oneof) props[field.oneof + ': undefined'] = true;
}
return '{' + Object.keys(props).join(', ') + '}';
}
Expand Down Expand Up @@ -295,7 +295,7 @@ function getDefaultValue(field, value) {
case 'string': return value || '';
case 'bool': return value === 'true';
case 'map': return {};
default: return null;
default: return undefined;
}
}

Expand Down

0 comments on commit 7b723c1

Please sign in to comment.