-
Notifications
You must be signed in to change notification settings - Fork 600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeScript import @google-cloud/tasks error #5683
Comments
The Workaround 1 is posing another challenge. Fix for #5000 requires upgrading the @google-cloud/tasks to 5.2.1+, but you can't build it above 4.0.1. 😠 |
The reason for this is that @google-cloud/tasks is now published as a dual-format ESM and CJS module as of 5.0. Using NodeNext tells the compiler to import as ESM if you're using imports. One option is to use dynamic imports, like you said, or you can just |
@danielbankhead as FYI for future notes to better explain this feature. |
I understand what is causing it, but the problem is that it's happening. None of the other @Google-Cloud packages have this problem (that I know of). @google-cloud/tasks didn't have this problem until recently either. A different design or way to export multiple format should be considered. I have started using dynamic imports as a workaround but regular import at the top of the file would be a much better option. Thank you. |
This is not correct. Typescript resolves the Reason that typescript misunderstands the module type is:
So this can be resolved if we correctly tell the NodeFormat of
|
Since this change, import is broken from TypeScript with
NodeNext
.https://github.com/googleapis/google-cloud-node/blame/6773a05ce96d64e4a1034e8b63ef6ec0d6688fd2/packages/google-cloud-tasks/package.json#L14
Code generating the error:
Error message:
tsconfig.json:
Workaround 1: Downgrade to 4.0.1.
Workaround 2: Use dynamic import.
The text was updated successfully, but these errors were encountered: