How to translate Cloud Vision function sample for firebase to javascript?

I would like to integrate cloud vision functionality into my firebase app without having to migrate my project to typescript at this time. All of my cloud functions are written in javascript. How might one translate the typescript example provided here (below for reference) to plain old javascript?

import vision from "@google-cloud/vision";

const client = new vision.ImageAnnotatorClient();

export const annotateImage = functions.https.onCall(async (data, context) => {
  if (!context.auth) {
    throw new functions.https.HttpsError(
      "annotateImage must be called while authenticated."
  try {
    return await client.annotateImage(JSON.parse(data));
  } catch (e) {
    throw new functions.https.HttpsError("internal", e.message, e.details);


I don’t see any type annotations in the code you shared, so it looks like that plain-old JavaScript already. You should be able to paste it into your index.js files and use it as is.

If you ever find a file that contains type annotations and you want to use it in a pure JavaScript setting, you can use a tool like this TypeScript playground to convert TypeScript to JavaScript.