ts-proto icon indicating copy to clipboard operation
ts-proto copied to clipboard

fix: usePrototypeForDefaults with repeated fix

Open alexeyten opened this issue 3 years ago • 1 comments

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.

alexeyten avatar Feb 04 '22 23:02 alexeyten

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.

stephenh avatar Aug 20 '23 22:08 stephenh