gapic-generator-typescript icon indicating copy to clipboard operation
gapic-generator-typescript copied to clipboard

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

Open feywind opened this issue 1 year ago • 1 comments

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, null>,
        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.

feywind avatar Feb 12 '25 21:02 feywind