Skip to content

Commit f1fe5db

Browse files
Update the defaultValue check to allow for falsy and undefined values (#4838)
# Description of Changes This fixes a bug in TypeScript table default serialization where falsy defaults like 0, '', false, and explicit undefined were treated as if no default was provided. I did this as a property check in order to allow `undefined` which becomes None() as the API allows `T | undefined`. Closes: #4700 # API and ABI breaking changes N/A # Expected complexity level and risk 1 - Simple change to check the default value was added as a property # Testing - [x] Reproduced the failing issue in a simple throwaway project
1 parent 6f23b19 commit f1fe5db

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

  • crates/bindings-typescript/src/lib

crates/bindings-typescript/src/lib/table.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,8 @@ export function table<Row extends RowObj, const Opts extends TableOpts<Row>>(
411411
});
412412
}
413413

414-
if (meta.defaultValue) {
414+
// Check for defaultValue on the property to allow for 0, false, '', and undefined as defaults
415+
if (Object.prototype.hasOwnProperty.call(meta, 'defaultValue')) {
415416
const writer = new BinaryWriter(16);
416417
builder.serialize(writer, meta.defaultValue);
417418
defaultValues.push({

0 commit comments

Comments
 (0)