Skip to content

Commit 7b723c1

Browse files
authored
Use undefined instead of null as default value
This fixes the type issues in mapbox#107. Also it makes more sense. I'm unsure about the `return undefined`.
1 parent b4eab64 commit 7b723c1

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

compile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ function compileDest(ctx) {
101101
for (var i = 0; i < ctx._proto.fields.length; i++) {
102102
var field = ctx._proto.fields[i];
103103
props[field.name + ': ' + JSON.stringify(ctx._defaults[field.name])] = true;
104-
if (field.oneof) props[field.oneof + ': null'] = true;
104+
if (field.oneof) props[field.oneof + ': undefined'] = true;
105105
}
106106
return '{' + Object.keys(props).join(', ') + '}';
107107
}
@@ -295,7 +295,7 @@ function getDefaultValue(field, value) {
295295
case 'string': return value || '';
296296
case 'bool': return value === 'true';
297297
case 'map': return {};
298-
default: return null;
298+
default: return undefined;
299299
}
300300
}
301301

0 commit comments

Comments
 (0)