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

[BUG]: CJS/ESM related TS issues #650

Closed
1 task done
Maxim-Mazurok opened this issue Sep 29, 2024 · 8 comments · Fixed by #651
Closed
1 task done

[BUG]: CJS/ESM related TS issues #650

Maxim-Mazurok opened this issue Sep 29, 2024 · 8 comments · Fixed by #651
Labels
released Type: Bug Something isn't working as documented, or is being fixed

Comments

@Maxim-Mazurok
Copy link
Contributor

What happened?

Hello, I don't skip libcheck in my TSC, and started getting these errors since that latest update (13.6.0):

node_modules/@octokit/core/dist-types/types.d.ts:1:31 - 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("@octokit/types")' call instead.

1 import * as OctokitTypes from "@octokit/types";

It was working fine on 13.5.0 before

See for details: Maxim-Mazurok/google-api-typings-generator#1079 and https://github.com/Maxim-Mazurok/google-api-typings-generator/actions/runs/11089432725/job/30810552166?pr=1079#step:5:1

Versions

@octokit/types: 13.6.0 (all worked fine with 13.5.0)

@octokit/core: 5.2.0
@octokit/graphql: 7.1.0
@octokit/plugin-paginate-rest: 11.3.1
@octokit/plugin-rest-endpoint-methods: 13.2.2
@octokit/request: 8.4.0
@octokit/request-error: 5.1.0

Relevant log output

> tsc --noEmit

node_modules/@octokit/core/dist-types/types.d.ts:1:31 - 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("@octokit/types")' call instead.

1 import * as OctokitTypes from "@octokit/types";
                                ~~~~~~~~~~~~~~~~

node_modules/@octokit/graphql/dist-types/error.d.ts:1:38 - 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("@octokit/types")' call instead.

1 import type { ResponseHeaders } from "@octokit/types";
                                       ~~~~~~~~~~~~~~~~

node_modules/@octokit/graphql/dist-types/types.d.ts:1:101 - 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("@octokit/types")' call instead.

1 import type { EndpointOptions, RequestParameters as RequestParametersType, EndpointInterface } from "@octokit/types";
                                                                                                      ~~~~~~~~~~~~~~~~

node_modules/@octokit/plugin-paginate-rest/dist-types/generated/paginating-endpoints.d.ts:1:32 - 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("@octokit/types")' call instead.

1 import type { Endpoints } from "@octokit/types";
                                 ~~~~~~~~~~~~~~~~

node_modules/@octokit/plugin-paginate-rest/dist-types/types.d.ts:2:31 - 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("@octokit/types")' call instead.

2 import * as OctokitTypes from "@octokit/types";
                                ~~~~~~~~~~~~~~~~

node_modules/@octokit/plugin-paginate-rest/dist-types/types.d.ts:3:100 - 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("@octokit/types")' call instead.

3 export type { EndpointOptions, RequestInterface, OctokitResponse, RequestParameters, Route, } from "@octokit/types";
                                                                                                     ~~~~~~~~~~~~~~~~

node_modules/@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types.d.ts:1:58 - 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("@octokit/types")' call instead.

1 import type { EndpointInterface, RequestInterface } from "@octokit/types";
                                                           ~~~~~~~~~~~~~~~~

node_modules/@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types.d.ts:1:51 - 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("@octokit/types")' call instead.

1 import type { Endpoints, RequestParameters } from "@octokit/types";
                                                    ~~~~~~~~~~~~~~~~

node_modules/@octokit/plugin-rest-endpoint-methods/dist-types/types.d.ts:1:47 - 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("@octokit/types")' call instead.

1 import type { Route, RequestParameters } from "@octokit/types";
                                                ~~~~~~~~~~~~~~~~

node_modules/@octokit/request-error/dist-types/index.d.ts:1:71 - 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("@octokit/types")' call instead.

1 import type { RequestOptions, ResponseHeaders, OctokitResponse } from "@octokit/types";
                                                                        ~~~~~~~~~~~~~~~~

node_modules/@octokit/request-error/dist-types/types.d.ts:1:71 - 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("@octokit/types")' call instead.

1 import type { RequestOptions, ResponseHeaders, OctokitResponse } from "@octokit/types";
                                                                        ~~~~~~~~~~~~~~~~

node_modules/@octokit/request/dist-types/index.d.ts:1:38 - 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("@octokit/types")' call instead.

1 export declare const request: import("@octokit/types").RequestInterface<object>;
                                       ~~~~~~~~~~~~~~~~


Found 12 errors in 11 files.

Errors  Files
     1  node_modules/@octokit/core/dist-types/types.d.ts:1
     1  node_modules/@octokit/graphql/dist-types/error.d.ts:1
     1  node_modules/@octokit/graphql/dist-types/types.d.ts:1
     1  node_modules/@octokit/plugin-paginate-rest/dist-types/generated/paginating-endpoints.d.ts:1
     2  node_modules/@octokit/plugin-paginate-rest/dist-types/types.d.ts:2
     1  node_modules/@octokit/plugin-rest-endpoint-methods/dist-types/generated/method-types.d.ts:1
     1  node_modules/@octokit/plugin-rest-endpoint-methods/dist-types/generated/parameters-and-response-types.d.ts:1
     1  node_modules/@octokit/plugin-rest-endpoint-methods/dist-types/types.d.ts:1
     1  node_modules/@octokit/request-error/dist-types/index.d.ts:1
     1  node_modules/@octokit/request-error/dist-types/types.d.ts:1
     1  node_modules/@octokit/request/dist-types/index.d.ts:1

Code of Conduct

  • I agree to follow this project's Code of Conduct
@Maxim-Mazurok Maxim-Mazurok added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented, or is being fixed labels Sep 29, 2024
Copy link
Contributor

👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! We have a process in place for prioritizing and responding to your input. Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

halostatue added a commit to KineticCafe/actions-dco that referenced this issue Oct 2, 2024
halostatue added a commit to KineticCafe/actions-dco that referenced this issue Oct 2, 2024
halostatue added a commit to KineticCafe/actions-dco that referenced this issue Oct 2, 2024
@kanadgupta
Copy link

ATTW is a good resource for validating types and that also seems to indicate that @octokit/[email protected] shipped bad types:

https://arethetypeswrong.github.io/?p=@octokit/[email protected]
https://arethetypeswrong.github.io/?p=@octokit/[email protected]

@Maxim-Mazurok
Copy link
Contributor Author

@wolfy1339
Copy link
Member

It is a type only package after all, ESM vs CJS it doesn't matter.

Please note that it is not advised to depend on @octokit/types in your package, as having multiple versions can negatively affect your typescript experience. The types are closely tied to each version of the rest plugins

I do know about ATTW.

I will have a patch to fix these issues ASAP

@Maxim-Mazurok
Copy link
Contributor Author

Yeah, I do not depend on this package directly, but I compile my dependencies that do (using skipLibCheck: false)

Thanks for the prompt response and PR!

@wolfy1339 wolfy1339 removed the Status: Triage This is being looked at and prioritized label Oct 3, 2024
@wolfy1339 wolfy1339 moved this from 🆕 Triage to 🏗 In progress in 🧰 Octokit Active Oct 3, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in 🧰 Octokit Active Oct 3, 2024
@octokitbot
Copy link
Collaborator

🎉 This issue has been resolved in version 13.6.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@oscard0m
Copy link
Member

oscard0m commented Oct 3, 2024

@Maxim-Mazurok thanks for reporting this and thanks @wolfy1339 for the PR.

@Maxim-Mazurok now we need Renovate to wait to do its job and merge all the subsequent PRs. As soon as everything is published, let us know if it solves your issue.

@wolfy1339
Copy link
Member

wolfy1339 commented Oct 3, 2024

They are using the previous version of the Octokit libraries that is still CJS. They won't get a new version from these updates.

Refreshing their lockfiles should fix this issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
released Type: Bug Something isn't working as documented, or is being fixed
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants