Skip to content

Commit

Permalink
Fix generated create() method for speed optimized code
Browse files Browse the repository at this point in the history
  • Loading branch information
timostamm committed Aug 31, 2021
1 parent 92c42c0 commit 0534891
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

none

Bug fixes:

- Generated `create()` method for speed optimized code got left behind in #55
Thanks to @odashevskii-plaid for the find!


### v2.0.2

Expand Down
1 change: 1 addition & 0 deletions packages/plugin/src/code-gen/message-type-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ export class MessageTypeGenerator extends GeneratorBase {
// "MyMessage$Type" members for optimized binary format
if (optimizeFor === OptimizeMode.SPEED) {
classDecMembers.push(
...this.typeMethodCreate.make(source, descriptor),
...this.typeMethodInternalBinaryRead.make(source, descriptor),
...this.typeMethodInternalBinaryWrite.make(source, descriptor),
);
Expand Down
2 changes: 1 addition & 1 deletion packages/plugin/src/message-type-extensions/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export class Create implements CustomMethodGenerator {
makeMethod(source: TypescriptFile, descriptor: DescriptorProto, ...bodyStatements: readonly ts.Statement[]): ts.MethodDeclaration {
const
MessageInterface = this.imports.type(source, descriptor),
PartialMessage = this.imports.name(source,'PartialMessage', this.options.runtimeImportPath)
PartialMessage = this.imports.name(source,'PartialMessage', this.options.runtimeImportPath, true)
;
return ts.createMethod(undefined, undefined, undefined, ts.createIdentifier("create"), undefined, undefined,
[
Expand Down

0 comments on commit 0534891

Please sign in to comment.