Skip to content

CJS vs ESM import issue? #2914

Open
Open
@risalfajar

Description

@risalfajar

[READ] Step 1: Are you in the right place?

Yes

[REQUIRED] Step 2: Describe your environment

  • Operating System version: MacOS 15.4.1
  • Firebase SDK version: firebase-admin 12.5.0
  • Firebase Product: storage
  • Node.js version: 20.13.1
  • NPM version: 10.8.0

[REQUIRED] Step 3: Describe the problem

Basically what happened here. It's just there has been no answer to that, only workaround, so I post it here.

Happened to me when importing:

import type { File } from "@google-cloud/storage";

It says:

TS2322: Type
import("/WebstormProjects/firebase/functions/node_modules/@google-cloud/storage/build/cjs/src/file").File
is not assignable to type
import("/WebstormProjects/firebase/functions/node_modules/@google-cloud/storage/build/esm/src/file", { with: { "resolution-mode": "import" } }).File
Property #private in type File refers to a different member that cannot be accessed from within type File

Steps to reproduce:

Create Firebase Cloud Functions project using typescript and ESM.

Relevant Code:

tsconfig:

    "module": "Node16",
    "moduleResolution": "Node16",
    "target": "es2020",

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions