CJS vs ESM import issue?
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 30/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- node.js, typescript
调研方向
首先,在使用 ESM、Node.js 20.13.1、firebase-admin 12.5.0 以及所示 Node16 tsconfig 的 Firebase Cloud Functions TypeScript 项目中复现报告的赋值错误。比较 @google-cloud/storage 的 CJS 和 ESM File 类型,以及 issue 中链接的讨论;当原因和适当的项目级解决方案确定后,即表示完成。
由索引模型根据 Issue 内容生成。
描述
[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",
- 主要语言
- TypeScript
- 星标
- 1.7k
- 派生
- 419
- 平均合并
- 4 天 20 小时
- 30 天内合并 PR
- 16
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/firebase-admin-node 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 35/100
firebase/firebase-admin-node#3234 ·
-
firebase/firebase-admin-node#3221 · 3 条评论 · 已指派 1 人 ·
-
api: messaging
难度 3/5 1-2 天 新手友好度 70/100
firebase/firebase-admin-node#3215 ·
-
api: messaging
难度 5/5 一周以上 新手友好度 28/100
firebase/firebase-admin-node#3214 ·
-
api: firestore type: feature request
firebase/firebase-admin-node#3183 · 1 条评论 · 已指派 1 人 ·
查看 firebase/firebase-admin-node 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
mksglu/context-mode#1200 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
jaegertracing/jaeger-ui#4506 ·
-
area:desktop area:ui bug platform:macos
难度 2/5 1-3 小时 新手友好度 75/100
anthropics/claude-code#96687 ·
-
good first issue
难度 1/5 1 小时以内 新手友好度 95/100
AOSSIE-Org/DebateAI#582 · 2 条评论 ·