Skip to content

fix(types): fix imports for type definitions#364

Closed
bjohansebas wants to merge 2 commits intomasterfrom
fix-typescript
Closed

fix(types): fix imports for type definitions#364
bjohansebas wants to merge 2 commits intomasterfrom
fix-typescript

Conversation

@bjohansebas
Copy link
Copy Markdown
Member

I’ve been doing some tests, and I think this is how the types will work correctly

fixed #363

cc @prigaux @takayukioda @kyota-fujikura could you review these changes and test them to verify that they work, please?

cc @clicktodev for the typescript wg

@coveralls
Copy link
Copy Markdown

coveralls commented Dec 15, 2025

Pull Request Test Coverage Report for Build 20556771105

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 93.874%

Totals Coverage Status
Change from base Build 20138541190: 0.0%
Covered Lines: 950
Relevant Lines: 1012

💛 - Coveralls

@takayukioda
Copy link
Copy Markdown

takayukioda commented Dec 16, 2025

@bjohansebas I've confirmed namespace import succeeds 👍🏽

% git diff
diff --git a/iconv-lite-not-found/package-lock.json b/iconv-lite-not-found/package-lock.json
index e259866..1cb8f73 100644
--- a/iconv-lite-not-found/package-lock.json
+++ b/iconv-lite-not-found/package-lock.json
@@ -6,7 +6,7 @@
     "": {
       "name": "iconv-lite-not-found",
       "dependencies": {
-        "iconv-lite": "0.7.1",
+        "iconv-lite": "github:pillarjs/iconv-lite#aa3107a",
         "typescript": "5.9.3"
       },
       "devDependencies": {
@@ -25,8 +25,7 @@
     },
     "node_modules/iconv-lite": {
       "version": "0.7.1",
-      "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.7.1.tgz",
-      "integrity": "sha512-2Tth85cXwGFHfvRgZWszZSvdo+0Xsqmw8k8ZwxScfcBneNUraK+dxRxRm24nszx80Y0TVio8kKLt5sLE7ZCLlw==",
+      "resolved": "git+ssh://git@github.com/pillarjs/iconv-lite.git#aa3107a192781ff899f83768a4939f7389bf0687",
       "license": "MIT",
       "dependencies": {
% npm run build                                           

> build
> tsc

@prigaux
Copy link
Copy Markdown

prigaux commented Dec 16, 2025

I confirm it fixes the issue :-)
Thanks!

@kyota-fujikura
Copy link
Copy Markdown

kyota-fujikura commented Dec 16, 2025

Thanks!

I tested this under ESM. The default import works as expected (with "esModuleInterop": true). However, the namespace import path compiles in TypeScript, but fails at runtime:

import * as iconv from "iconv-lite";
// (similarly: import { encode } from "iconv-lite";)

iconv.encode(input, encoding);
TypeError: iconv.encode is not a function

I’m not totally sure, but this might be a TypeScript/Node CJS↔ESM interop quirk (I’ve seen similar issues elsewhere). In any case, the default import working is enough for me for now. Thanks again!

@kyota-fujikura
Copy link
Copy Markdown

I noticed after commenting that the namespace import behaves the same way on v0.7.0 as well.

@bjohansebas
Copy link
Copy Markdown
Member Author

Closed in favor of #366 . Please review that PR and check that the changes there work as expected.

@bjohansebas bjohansebas deleted the fix-typescript branch December 29, 2025 03:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TypeScript types broken in ES Modules

5 participants