New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: usePrototypeForDefaults with repeated fix #499
base: main
Are you sure you want to change the base?
Conversation
cdf2835
to
7017d4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also running into this issue with my project. What are the next steps something like this fix in @stephenh ? Thanks!
@@ -1004,42 +1011,49 @@ export const SimpleWithMap = { | |||
const tag = reader.uint32(); | |||
switch (tag >>> 3) { | |||
case 1: | |||
message.entitiesById ||= []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't all the properties under this SimpleWithMap
be instantiated with an empty object, i.e. {}
instead of array?
@@ -736,7 +736,7 @@ function generateBaseInstanceFactory( | |||
: isMapType(ctx, messageDesc, field) | |||
? '{}' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to account the map case as well?
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 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. |
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.