Open
Description
Please make sure you have searched for information in the following guides.
- Search the issues already opened: https://github.com/GoogleCloudPlatform/google-cloud-node/issues
- Search StackOverflow: http://stackoverflow.com/questions/tagged/google-cloud-platform+node.js
- Check our Troubleshooting guide: https://github.com/googleapis/google-cloud-node/blob/main/docs/troubleshooting.md
- Check our FAQ: https://github.com/googleapis/google-cloud-node/blob/main/docs/faq.md
- Check our libraries HOW-TO: https://github.com/googleapis/gax-nodejs/blob/main/client-libraries.md
- Check out our authentication guide: https://github.com/googleapis/google-auth-library-nodejs
- Check out handwritten samples for many of our APIs: https://github.com/GoogleCloudPlatform/nodejs-docs-samples
A screenshot that you have tested with "Try this API".
N/A - types issue
Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.
https://gist.github.com/prescottprue/b77e59c85941d2e93766e9055819da99
A step-by-step description of how to reproduce the issue, based on the linked reproduction.
- Import types via
import type { Storage, File } from '@google-cloud/storage
(typescript by default uses cjs types unless you are doing full ESM - Dynamically import lib functionality via:
const { Storage } = await import('@google-cloud/storage')`
const storage = new Storage() // <- is ESM types, not CSJ
const file = storage.bucket(bucket).file(filePath) // not the same as File type
A clear and concise description of what the bug is, and what you expected to happen.
CJS types are pulled in when import type
if repo is not ESM, but using dynamic import causes ESM types to be pulled in. Since the types are not the same there is an error saying:
Type 'import(".../node_modules/@google-cloud/storage/build/esm/src/file", { with: { "resolution-mode": "import" } }).File' is not assignable to type 'import(".../identity-service/node_modules/@google-cloud/storage/build/cjs/src/file").File'.
Property '#private' in type 'File' refers to a different member that cannot be accessed from within type 'File'.
I've also tried the resolution-mode on both the import and the type import but that didn't work (regardless of import/reuqire setting):
import type { Storage, File } from '@google-cloud/storage' with { "resolution-mode": "import" };
// or
import type { Storage, File } from '@google-cloud/storage' with { "resolution-mode": "require" };
const { Storage } = await import('@google-cloud/storage', { with: { 'resolution-mode': 'import' } })
// or
const { Storage } = await import('@google-cloud/storage', { with: { 'resolution-mode': 'require' } })
A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **
It is expected that the types match between cjs and esm as they do with @google-cloud/pubsub
: https://github.com/googleapis/nodejs-pubsub/blob/main/package.json. With PubSub lib dynamic import is no issue