Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

CJS vs ESM import issue?

Đang mở
#2,914 0 bình luận 3 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
30/100
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
node.js, typescript
Lĩnh vực
backend, cloud

Hướng nghiên cứu

Bắt đầu bằng cách tái hiện lỗi gán được báo cáo trong một dự án Firebase Cloud Functions TypeScript sử dụng ESM, Node.js 20.13.1, firebase-admin 12.5.0 và tsconfig Node16 được cung cấp. So sánh các kiểu File CJS và ESM của @google-cloud/storage cùng với cuộc thảo luận được liên kết trong issue; công việc được xem là hoàn tất khi nguyên nhân và một cách giải quyết phù hợp ở cấp dự án đã được xác định.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

api: storage
[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",
Ngôn ngữ chính
TypeScript
Star
1.7k
Fork
419
Merge trung bình
4 ngày 20 giờ
Pull request đã merge (30 ngày)
16

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của firebase/firebase-admin-node

Tất cả issue của firebase/firebase-admin-node

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.