Skip to content

Missing Type Exports in ffi/npm/package.json #6695

@Vizards

Description

@Vizards

When using the icu package in a TypeScript project, I encountered an error Typescript Could not find a declaration file for module 'icu'..

Image

This seems to be because there is no explicit export for the type definitions corresponding to ./lib/index.mjs in ffi/npm/package.json. Specifically, the package currently does not export ./lib/index.d.ts.

After making the following changes to package.json, TypeScript is able to correctly resolve the type definitions for the icu package:

  "exports": {
-    ".": "./lib/index.mjs"
+    ".": {
+      "import": "./lib/index.mjs",
+      "types": "./lib/index.d.ts"
     }
  },

Alternatively, renaming ./lib/index.d.ts to ./lib/index.d.mts also resolves the issue, since TypeScript enforces stricter rules for automatic type resolution with mjs files.
However, the contents of the lib directory are generated by Diplomat, and I couldn’t find an option in Diplomat to change the file extension for generated type definitions.

BTW, I noticed that version 2.0.4 of icu has been published on npm, but ffi/README.md does not appear to be updated yet.

Although this is a fairly simple change, I would be happy to open a Pull Request to help address this issue—just let me know if that would be helpful!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions