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]: An import path cannot end with a '.ts' extension #2597

Closed
1 task done
kanocarra opened this issue Dec 20, 2023 · 4 comments · Fixed by octokit/webhooks.js#949
Closed
1 task done

[BUG]: An import path cannot end with a '.ts' extension #2597

kanocarra opened this issue Dec 20, 2023 · 4 comments · Fixed by octokit/webhooks.js#949
Labels
Type: Bug Something isn't working as documented

Comments

@kanocarra
Copy link

kanocarra commented Dec 20, 2023

What happened?

Upgraded from version 2.1.0 to 3.1.2 of octokit and receiving the above error when building in typescript:

import type { Logger } from "./createLogger.ts";
                              ~~~~~~~~~~~~~~~~~~~
node_modules/@octokit/webhooks/dist-types/types.d.ts:4:40 - error TS2691: An import path cannot end with a '.ts' extension. Consider importing './generated/webhook-names' instead.

If I downgrade to 2.x.x I no longer have this problem and can see in the @octokit/webhooks/dist-types/types.d.ts folder that the import changes to

import type { Logger } from "./createLogger";

Thus removing the .ts extension.

I have added allowImportingTsExtensions: true in my tsconfig.json but still see this error? I would expect this to build without error.

Anyone have any ideas?

Versions

Octokit v3.2.1 Node.js 18.15 Typescript 4.7.4

Relevant log output

node_modules/@octokit/webhooks/dist-types/middleware/node/types.d.ts:1:29 - error TS2691: An import path cannot end with a '.ts' extension. Consider importing '../../createLogger' instead.

1 import type { Logger } from "../../createLogger.ts";
                              ~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@octokit/webhooks/dist-types/types.d.ts:3:29 - error TS2691: An import path cannot end with a '.ts' extension. Consider importing './createLogger' instead.

3 import type { Logger } from "./createLogger.ts";
                              ~~~~~~~~~~~~~~~~~~~
node_modules/@octokit/webhooks/dist-types/types.d.ts:4:40 - error TS2691: An import path cannot end with a '.ts' extension. Consider importing './generated/webhook-names' instead.

4 import type { emitterEventNames } from "./generated/webhook-names.ts";
                                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Found 3 error(s).

Code of Conduct

  • I agree to follow this project's Code of Conduct
@kanocarra kanocarra added Status: Triage This is being looked at and prioritized Type: Bug Something isn't working as documented labels Dec 20, 2023
Copy link

👋 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 labled with Status: Up for grabs. You & others like you are the reason all of this works! So thank you & happy coding! 🚀

@wolfy1339
Copy link
Member

wolfy1339 commented Dec 20, 2023

Thank you for bringing this up!

Indeed, the import is using a .ts extension. While that is allowed using the allowImportingTsExtensions that only works with the noemit option.

The correct fix would be to simply replace it with a .js extension

Would you like to submit a PR with a fix?

@wolfy1339 wolfy1339 removed the Status: Triage This is being looked at and prioritized label Dec 20, 2023
@wolfy1339 wolfy1339 moved this from 🆕 Triage to 🔥 Backlog in 🧰 Octokit Active Dec 20, 2023
@kanocarra
Copy link
Author

Hey @wolfy1339 I actually managed to fix it! Unfortunately I can't use the noEmit option as this is for a nestJS runtime so need the built files output.

Upgrading to typescript v5.3.3 seemed to fix the build issue so all resolved now ✅ For anyone who has the same issue, just upgrade your typescript! Happy to leave as is unless you think worth fixing?

Thanks

@wolfy1339
Copy link
Member

I think you overlooked the last part of my last comment.

I understand you can't use the noEmit option, I wasn't suggesting as such, just pointing it out.

Upgrading Typescript definitely does help.

Replacing the .ts with .js in the offending import would fix this problem for everybody

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

Successfully merging a pull request may close this issue.

2 participants