-
So I'm trying to upgrade my modules to ESM, which I've done by setting However I'm running into a few type issues. If I import Typescript will then complain that the two types are not compatible. import { storage } from 'firebase-admin'
import { Bucket } from '@google-cloud/storage'
const bucket: Bucket = storage().bucket()
How do I solve this "correctly"? I can solve the above import type { Storage } from 'firebase-admin/storage'
type Bucket = ReturnType<Storage['bucket']> but this quickly gets very complicated, as the next type I need to extract is Help would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
So a workaround is doing: import type { Bucket } from '@google-cloud/storage/build/cjs/src/bucket.d.ts' And then adding the "paths": {
"@google-cloud/storage/build/cjs/src/bucket.d.ts": ["./node_modules/@google-cloud/storage/build/cjs/src/bucket.d.ts"]
} This basically screams "fix me later". |
Beta Was this translation helpful? Give feedback.
-
Please reopen this, this also happened to me when importing: import type { File } from "@google-cloud/storage"; Error message: 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 |
Beta Was this translation helpful? Give feedback.
So a workaround is doing:
And then adding the
bucket.d.ts
topaths
in tsconfig's `compilerOptions:This basically screams "fix me later".