Skip to content

Commit

Permalink
Add types unconditionally
Browse files Browse the repository at this point in the history
  • Loading branch information
bduffany committed May 13, 2024
1 parent c59452e commit 83709a9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion codegen.go
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,9 @@ func (c *Codegen) generate(file *descriptorpb.FileDescriptorProto, sourcePath []

// Generate services
for serviceIndex, serviceType := range services {
// Add type definitions required by services
d.AddTopLevelDeclaration(streamTypeDeclarations)

servicePath := append(sourcePath, fileDescriptorServiceTagNumber, int32(serviceIndex))
d.BlockComment(c.Comments[file.GetName()][fmt.Sprint(servicePath)])

Expand All @@ -782,7 +785,6 @@ func (c *Codegen) generate(file *descriptorpb.FileDescriptorProto, sourcePath []
methodPath := append(servicePath, serviceMethodTagNumber, int32(methodIndex))
d.BlockComment(c.Comments[file.GetName()][fmt.Sprint(methodPath)])
if method.GetServerStreaming() {
d.AddTopLevelDeclaration(streamTypeDeclarations)
d.Lf(`%s: { readonly name: "%s"; readonly serverStreaming: true; } & ((request: %s, handler: $stream.ServerStreamHandler<%s>) => $stream.ServerStream<%s>);`,
serviceMethodJSName(method), method.GetName(), interfaceTypeName(c.resolveTypeName(method.GetInputType(), "")), c.resolveTypeName(method.GetOutputType(), ""), c.resolveTypeName(method.GetOutputType(), ""))
} else {
Expand Down

0 comments on commit 83709a9

Please sign in to comment.