nodejs-vision icon indicating copy to clipboard operation
nodejs-vision copied to clipboard

Incomplete ImprovedRequest TypeScript interface

Open clorichel opened this issue 3 years ago • 3 comments

Environment details

  • OS: irrelevant
  • Node.js version: irrelevant
  • npm version: irrelevant
  • @google-cloud/vision version: 2.4.0

Steps to reproduce

const client = new vision.ImageAnnotatorClient();
const [result] = await client.cropHints({ image: { source: { filename } }, imageContext: {} });

Gives you an 'imageContext' does not exist in type 'ImprovedRequest | Buffer' TypeScript error.

Description

That might not be an issue only for the cropHints feature, but any ImageAnnotatorClient feature which method signature is equivalent/limited to (request: string | ImprovedRequest | Buffer).

The appropriate JSON representation is documented here: https://cloud.google.com/vision/docs/reference/rest/v1/AnnotateImageRequest where we can see that imageContext is possible, yet not in this package ImprovedRequest interface. Then one could drill it down to https://cloud.google.com/vision/docs/reference/rest/v1/ImageContext to actually provide a thorough interface.

Workaround

The request actually works fine if you simply cast the method parameter through client.cropHints({ image: { source: { filename } }, imageContext: {} } as any): the imageContext is passed down to the underlying service and used as one could expect to generate the response.

clorichel avatar Nov 09 '21 11:11 clorichel

I'm facing this issue right now.

Tobjoern avatar Dec 19 '21 20:12 Tobjoern

Will take deep look in Jan and keep post here.

summer-ji-eng avatar Jan 05 '22 08:01 summer-ji-eng

@galz10 @bcoe could you help to take a look at here? ImprovedRequest is from helper.ts, which is not generated from gapic-generator-typescript. I wonder if it is a manual layer.

summer-ji-eng avatar Jan 07 '22 01:01 summer-ji-eng