-
Notifications
You must be signed in to change notification settings - Fork 76
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
Make wrappers more lenient #291
Conversation
Fixes #283 by removing code path that errors. We can easily and reliably determine whether a field is already wrapped by checking if it is `instanceof Message`.
describe("mixing message instances", () => { | ||
const message = new TS_MessageFieldMessage(); | ||
message.messageField = new JS_MessageFieldMessage_TestMessage({ | ||
name: "foo", | ||
}); |
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 covers the use case of #283 by using a message of the JavaScript generated code for a field of a message from the TypeScript generated code, proving that we no longer error.
Also added many more tests around wrappers.
wrapField(value: number): DoubleValue { | ||
return new DoubleValue({value}); | ||
}, |
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 simplifies the generated code by making the internal function wrapField
idempotent instead of this FieldWrapper. I don't like changing this, but it the generated code does look quite a bit nicer...
This release includes the following: ## Enhancements * Add a toJSON method to messages by @smaye81 in #306 * Add an unpack function to `google.protobuf.Any` by @smaye81 in #303 * Make generated imports look more normal by @dimitropoulos in #298⚠️ Note that as a result of this PR, import statements in your generated code will contain diffs when generated with `v0.3.0` as the import statements will have spaces added. For example: ```diff - import {FooMessage} from './foo_message_pb.js'; + import { FooMessage } from './foo_message_pb.js'; ``` * Add print function with tagged template literal by @yukukotani in #279 * Enhance the `Any.is` function by @smaye81 in #294 * Make wrappers more lenient by @timostamm in #291 ## Bugfixes * Fix map equality by @calebdoxsey in #305 * Make `tsNocheck` work correctly by @yukukotani in #275 ## New Contributors @calebdoxsey made their first contribution in #305 @yukukotani made their first contributions in #275 and #279
Fixes #283 by removing code path that errors. We can easily and reliably determine whether a field is already wrapped by checking if it is
instanceof Message
.