firebase / firebase/firebase-admin-node
CJS vs ESM import issue?
- Lingua principale
- TypeScript
- Stelle
- 1.7k
- Fork
- 419
- Merge medio
- 3g 10h
- PR unite (30g)
- 16
Descrizione
### [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](https://github.com/firebase/firebase-admin-node/discussions/2639). It's just there has been no answer to that, only workaround, so I post it here.
Happened to me when importing:
```ts
import type { File } from "@google-cloud/storage";
```
It says:
```console
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:
```json
"module": "Node16",
"moduleResolution": "Node16",
"target": "es2020",
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia riproducendo l’errore di assegnazione segnalato in un progetto Firebase Cloud Functions TypeScript che utilizza ESM, Node.js 20.13.1, firebase-admin 12.5.0 e il tsconfig Node16 mostrato. Confronta i tipi File CJS ed ESM di @google-cloud/storage e la discussione collegata nell’issue; il lavoro è completo quando sono state stabilite la causa e una risoluzione appropriata a livello di progetto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- node.js, typescript
- Ambito
- backend, cloud
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 30/100