Divyanshu-s13 opened a new pull request, #340:
URL: https://github.com/apache/arrow-js/pull/340
#90
Fix Summary for Issue #90: Strong typing for builders
Fix Summary for Issue #90: Strong Typing for Builders
Problem:
StructBuilder.append() was expecting a StructRowProxy<T> type, which
includes internal properties and methods such as toArray(), toJSON(),
[kRowIndex], [kParent], and iterator symbols. Because of this, users could not
pass plain JavaScript objects as values, even though that is the intended usage
pattern.
Cause:
The root issue was the way the Struct type’s TValue was constructed in
type.ts, where the typing used { } & { } intersections. This resulted in an
overly strict type that forced the builder to expect the proxy type instead of
a simple object literal.
Solution:
Adjusted the TValue definition within the Struct type in type.ts to
correctly map the struct’s fields to plain JavaScript object shapes. This
allows StructBuilder.append() to accept standard JS objects without requiring
internal proxy fields.
// Before:
TValue: StructRowProxy<T>;
// After:
TValue: StructRowProxy<T> | { [P in keyof T]: T[P]['TValue'] };
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]