ts-proto
ts-proto copied to clipboard
fix: usePrototypeForDefaults with repeated fix
Just an idea how to fix #498.
Declare repeated fields as “possibly undefined” and create them on demand. So “hazzle check” would still work, but callers will have to create array manually.
Hi @pbhuynh , just taking a look--sorry @alexeyten , you had some great work here, and I must not have had time to review it/think about it when you first submitted the PR.
In terms of approach, I think if I was personally using usePrototypeForDefaults with repeated fields all day, every day, I'd probably try to implement @alexeyten 's "auto-set on read" ideas, which seem pretty neat/ergonomic.
That said, I think what the current PR is doing, just making the repeated fields undefined, is probably more straight-forward/an easier path to getting merged.
Just in general @pbhuynh , I think next steps would be 1) getting the PR rebased and 2) have a clear "failed before, passing now" test/reproduction in the integration tests.