Last active
November 14, 2024 01:34
-
-
Save prescottprue/b77e59c85941d2e93766e9055819da99 to your computer and use it in GitHub Desktop.
Google Cloud Storage ESM/CJS Type Mismatch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Storage, File } from '@google-cloud/storage' with { "resolution-mode": "import" } | |
async function someFunc(): Promise<File> { | |
const { Storage } = await import('@google-cloud/storage') | |
const storage = new Storage() // <- is ESM types, not CSJ | |
return storage.bucket(bucket).file(filePath) // not the same as File type | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Storage, File } from '@google-cloud/storage' // causes CJS types to be imported | |
async function someFunc(): Promise<File> { | |
const { Storage } = await import('@google-cloud/storage', { with: { "resolution-mode": "require" } }) | |
const storage = new Storage() // <- is ESM types, not CSJ | |
return storage.bucket(bucket).file(filePath) // not the same as File type | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { Storage, File } from '@google-cloud/storage' // causes CJS types to be imported | |
async function someFunc(): Promise<File> { | |
const { Storage } = await import('@google-cloud/storage') | |
const storage = new Storage() // <- is ESM types, not CSJ | |
return storage.bucket(bucket).file(filePath) // not the same as File type | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment