Skip to content

toExports with includeType=true creates duplicate identifiers for classes #498

Closed

Description

@aklinker1

Environment

  • Unimport: 5.6.0
  • Bun: 1.3.8
  • Node: 24.7.0

Reproduction

https://github.com/aklinker1/unimport-class-issue-reproduction

Run it via:

bun install
bun index.ts

# or for node versions that support type-stripping
npm install
node index.ts

Both node and bun behave the same.

Describe the bug

The script is very simple: scan a directory and export all it's values and types.

https://github.com/aklinker1/unimport-class-issue-reproduction/blob/3a8db4ca37131833fae589aac5f2afbc9bec81b4/index.ts#L1C1-L11C39

However, this code produces an invalid export:

export { Foo, Foo } from '/path/to/reproduction/src/Foo';

It's trying to import the class value and type separately.

Is this intentional? Does the code need to filter the imports list before passing it into toExports or should toExports handle this case?

Additional context

Originally reported in WXT: wxt-dev/wxt#2064 (comment)

Logs

Imports: [
  {
    name: 'Foo',
    as: 'Foo',
    from: '/path/to/reproduction/utils/Foo.ts'
  },
  {
    name: 'Foo',
    as: 'Foo',
    from: '/path/to/reproduction/utils/Foo.ts',
    type: true,
    declarationType: 'class'
  }
]

Exports:
export { Foo, Foo } from '/path/to/reproduction/utils/Foo';

Activity

  1. added
    bug
    on Feb 9, 2026
  2. added a commit that references this issue on Apr 14, 2026
    197c39a
  3. added a commit that references this issue on Apr 28, 2026
    28486d5
  4. aklinker1 commented on May 11, 2026

    @aklinker1
    Author

    Thanks for fixing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions