nodejs-compute
nodejs-compute copied to clipboard
Incorrect TypeScript definitions
Environment details
- OS: macOS 12.4
- Node.js version: 16.15.0
- npm version: 8.14.0
-
@google-cloud/compute
version: 3.4.0
Steps to reproduce
In a TypeScript project, create an AddressesClient
, use the #insert
method and attempt to read the status
of operation.latestResponse
. TypeScript compilation will fail.
import { AddressesClient } from "@google-cloud/compute";
const main = async () => {
const addressesClient = new AddressesClient();
const [operation] = await addressesClient.insert({ /* payload */ });
console.log(operation.latestResponse.status); // Complier Error: Property 'status' does not exist on type 'Operation'.
};
main()
.catch(console.error)
.finally(process.exit);
It looks like the latestResponse
is typed to to the google.longrunning.Operation
class. However upon inspection of the object in the debugger, latestResponse
is of type:
warnings: Array
id: String
kind: String
name: String
user: String
startTime: String
targetLink: String
progress: Number
region: String
operationType: String
status: String
targetId: String
clientOperationId: String
insertTime: String
selfLink: String
Thank you in advance!
Thank you for the report @cmdshepard. We are working for the full support for long running operations in the Compute client, I'm expecting to release the changes within a week or two, which should fix this issue as well (and make the await operation.promise()
actually work, because it does not work properly now).
Also reporting the same issue, seems the library is unusable with TypeScript unless you use any, not good.