googleapis/nodejs-vision

Incomplete ImprovedRequest TypeScript interface

clorichel opened this issue · 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.

I'm facing this issue right now.

Will take deep look in Jan and keep post here.

@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.