Skip to content

Fixed: add file extensions to all imports (for d.ts files) (#137)#211

Merged
adrai merged 1 commit intoi18next:mainfrom
danielrentz:issue137
Mar 5, 2026
Merged

Fixed: add file extensions to all imports (for d.ts files) (#137)#211
adrai merged 1 commit intoi18next:mainfrom
danielrentz:issue137

Conversation

@danielrentz
Copy link
Contributor

Fixes #137

  • added .js file extensions in import statements of all source files, there is no other way to convince TSC to write file extensions into the generated d.ts files
  • adjusted configuration of eslint-plugin-import to accept the file extensions (added TypeScript support, needs two new dev dependencies)
  • added one missing return type (the extract function) so TypeScript does not auto-generate Promise<import("../../types").Translationresult[]> without extension

This does not change the generated code in dist at all, Rollup has always added file extensions in all imports for both the esm and cjs builds.

Checklist

  • only relevant code is changed (make a diff before you submit the PR)
  • run tests npm run test
  • tests are included
  • commit message and code follows the Developer's Certification of Origin

Checklist (for documentation change)

  • only relevant documentation part is changed (make a diff before you submit the PR)
  • motivation/reason is provided
  • commit message and code follows the Developer's Certification of Origin

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedeslint-import-resolver-typescript@​4.4.49910010090100

View full report

@adrai
Copy link
Member

adrai commented Mar 5, 2026

feels "strange" to have ts files imported as .js but if this is the way it should work, i'm ok with that...

@danielrentz
Copy link
Contributor Author

It is strange indeed, there were already long discussions about that :)
You have to write it how the runtime will see it later. Although I am not sure if Rollup would rewrite .ts extensions to .js. TS would be happy with ts extensiond in the d.ts files. If you want, I can try that.

@adrai
Copy link
Member

adrai commented Mar 5, 2026

Yes, maybe before I merge this, please try what you can and let me know...

@danielrentz
Copy link
Contributor Author

Rollup issues errors when using ts extensions, and I did not find a way to fix this by using some options in tsconfig.json or rollup.config.js.

@adrai
Copy link
Member

adrai commented Mar 5, 2026

ok, then I merge

@adrai adrai merged commit 46e6e40 into i18next:main Mar 5, 2026
8 checks passed
@adrai
Copy link
Member

adrai commented Mar 5, 2026

included in v1.49.2

@danielrentz danielrentz deleted the issue137 branch March 6, 2026 07:23
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 this pull request may close these issues.

TypeScript types issue

2 participants