Skip to content
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 complains about import when used with moduleResolution node16 #313

Closed
lukahartwig opened this issue Jul 29, 2023 · 0 comments · Fixed by #314
Closed

TypeScript complains about import when used with moduleResolution node16 #313

lukahartwig opened this issue Jul 29, 2023 · 0 comments · Fixed by #314

Comments

@lukahartwig
Copy link
Member

lukahartwig commented Jul 29, 2023

When importing @vercel/postgres from a CommonJS module with "moduleResolution": "Node16" TypeScript resolves the ES module type declaration so it thinks it is importing an ES module. The result is a compilation error telling you to use a dynamic import.

A better explanation can be found here.

I found this when I tried to use @vercel/postgres but I'm pretty sure this happens in all packages in this repo.

I think the solution would be to remove the "types" field in package.json and let TypeScript infer the right file based on the name.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant