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

Can't enable lib checking in consumer tsconfig.json with ESM #679

Closed
fubhy opened this issue Jun 19, 2023 · 3 comments
Closed

Can't enable lib checking in consumer tsconfig.json with ESM #679

fubhy opened this issue Jun 19, 2023 · 3 comments
Labels
bug Something isn't working

Comments

@fubhy
Copy link
Contributor

fubhy commented Jun 19, 2023

Describe the bug

Currently, types are generated using ESM config but, unlike the files in dist/esm, do not have a parent package.json file with type: module. Hence, the types are considered CJS and cause typechecking errors when a consumer enables lib checking in their tsconfig.json.

To Reproduce

Set skipLibCheck: false in a consuming package and import from @bufbuild/connect. Since that imports from @bufbuild/protobuf (which has the types exported as ESM), you'll get the following error (and many others like it):

node_modules/@bufbuild/connect/dist/types/router.d.ts(1,46): error TS1479: The current file is a CommonJS module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dynamic 'import("@bufbuild/protobuf")' call instead.
@fubhy fubhy added the bug Something isn't working label Jun 19, 2023
@timostamm
Copy link
Member

Just catching up 😅

Good call - sounds like the "Masquerading as CJS" issue reported by arethetypeswrong. This should be fixed through #801.

@smaye81
Copy link
Member

smaye81 commented Sep 25, 2023

Hey @fubhy can your share your tsconfig compilerOptions? I'm guessing this is with moduleResolution of Node16 correct?

@smaye81
Copy link
Member

smaye81 commented Oct 5, 2023

This should be fixed in the v1.1.0 release. Release notes here.

@smaye81 smaye81 closed this as completed Oct 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants