-
Notifications
You must be signed in to change notification settings - Fork 349
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
feat: Initialize lists with map #387
feat: Initialize lists with map #387
Conversation
@webmaster128 yeah, I'm not really sure how that I merged #388 so am personally pretty willing to procrastinate on figuring out true root cause + better yet moving to a better This PR also looks great! Thanks! |
78f4a3e
to
869b65e
Compare
@@ -1249,7 +1225,7 @@ function generateFromPartial(ctx: Context, fullName: string, messageDesc: Descri | |||
chunks.push(code`message.${fieldName} = ${readSnippet(`object.${fieldName}`)};`); | |||
chunks.push(code`} else {`); | |||
const fallback = isWithinOneOf(field) ? 'undefined' : defaultValue(ctx, field); | |||
chunks.push(code`message.${fieldName} = ${fallback}`); | |||
chunks.push(code`message.${fieldName} = ${fallback};`); |
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.
This change is unrelated and simply here to increase consistency between generateFromPartial
and generateFromJson
.
Rebased. When it passes CI, I'm happy. |
# [1.86.0](v1.85.0...v1.86.0) (2021-11-15) ### Features * Initialize lists with map ([#387](#387)) ([200e674](200e674))
🎉 This PR is included in version 1.86.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This uses
map
to initialize lists, such that all cases can be handled within one assignment.if (object.ids !== undefined && object.ids !== null) {
was replaced withobject.ids ?? []
to save nesting depth and code size.