Skip to content

Type Declarations not Working for ESModule #17

Description

@neurolag

When trying to import this package from an ESModule TypeScript ecosystem, it won't work.
TypeScript shows an error stating that the corresponding types could not be found.

This is caused by the package.json setting the file for import calls to be index.mjs.
The setting mentioned before causes TypeScript to go search for the type declarations at gulp-esbuild/index.d.mts.

There are basically two ways on how to fix this:
A separate index.d.mts file can be created or - if both type declarations match - the types can be set to resolve to index.d.ts:

"exports": {
    "types": "./index.d.ts",
    "default": "./index.mjs"
}

Sadly, the type declarations do not match (index.js uses an export assignment, index.mjs uses a default export), so I think a separate type declaration file should be the proper solution.

I'll go create a PR concerning this matter.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions