Skip to content

TS compile errors in newly initialised Firebase Functions project #321

@maks

Description

@maks

I followed the instructions here to initialise my local dev environment to build Firebase Cloud Functions for use with Typescript.

I created this slightly modified example index.ts:

// The Cloud Functions for Firebase SDK to create Cloud Functions and set up triggers.
import * as functions from "firebase-functions";

// The Firebase Admin SDK to access Firestore.
import * as admin from "firebase-admin";


export const helloWorld = functions.https.onRequest(async (request, response) => {
  functions.logger.info("Hello logs!", {structuredData: true});

  // Push the new message into Firestore using the Firebase Admin SDK.
  const writeResult = await admin.firestore().collection('messages').add({m: "hi from test function"});

  response.send(`Message with ID: ${writeResult.id} added.`);
});

As per the instructions I then ran: npm run build
but instead of successful compilation I get:

> build
> tsc

node_modules/google-gax/build/protos/iam_service.d.ts:17:23 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.

17 import * as Long from 'long';
                         ~~~~~~

node_modules/google-gax/build/protos/operations.d.ts:17:23 - error TS2497: This module can only be referenced with ECMAScript imports/exports by turning on the 'esModuleInterop' flag and referencing its default export.

17 import * as Long from 'long';
                         ~~~~~~


Found 2 errors in 2 files.

Errors  Files
     1  node_modules/google-gax/build/protos/iam_service.d.ts:17
     1  node_modules/google-gax/build/protos/operations.d.ts:17

Environment details

  • OS: Linux
  • Node.js version: v16.14.0
  • npm version: 8.3.1
  • google-gax version: 2.30.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p2Moderately-important priority. Fix may not be included in next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions