googleapis / googleapis/google-cloud-node

(DI)REGAPIC generated Promise types in long running operations appear to be incorrect

Open
#7,693 1 comment 0 reactions 0 assignees View on GitHub
library: google-cloud-node-core priority: p2 size: s type: bug
Dominant language
TypeScript
Stars
3.2k
Forks
712
Avg merge
2d 3h
Merged PRs (30d)
99

Description

I noticed this when I was working on something else entirely, and I'm not sure I want to try to fix it as part of this (may be a breaking change even if it's wrong).

The template looks like this:

```
{%- if method.isDiregapicLRO %}
Promise<[
LROperation<{{ util.toInterface(method.outputInterface) }}, null>,
{{ util.toInterface(method.outputInterface) }}|undefined, {}|undefined
{%- else %}
Promise<[
{{ util.toInterface(method.outputInterface) }},
{{ util.toInterface(method.inputInterface) }}|undefined, {}|undefined
{%- endif %}
]>|void {
```

It seems to me like the intended difference between these two blocks is LROperation<> wrapping, versus not, but the first one has `method.outputInterface` twice. The generated code looks like this:

```
delete(
request?: protos.google.cloud.compute.v1.IDeleteAddressRequest,
optionsOrCallback?: CallOptions|Callback<
protos.google.cloud.compute.v1.IOperation,
protos.google.cloud.compute.v1.IDeleteAddressRequest|null|undefined,
{}|null|undefined>,
callback?: Callback<
protos.google.cloud.compute.v1.IOperation,
protos.google.cloud.compute.v1.IDeleteAddressRequest|null|undefined,
{}|null|undefined>):
Promise<[
LROperation,
protos.google.cloud.compute.v1.IOperation|undefined, {}|undefined
]>|void {
```

The Promise at the bottom shows IOperation twice, but the callbacks show IOperation and IDeleteAddressRequest (this is in compute cjs). This leads me to believe, given the parallels in the type thruple, that there's an issue here. Probably the second one in the Promise part should also be IDeleteAddressRequest.

#### Environment details

- Programming language: Generator templates
- OS: Linux
- Language runtime version: Node 18.12.0
- Package version: main

#### Steps to reproduce

- It's just part of the repo templates.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.