Skip to content

Cannot export a value if re-exporting a type with same name #42633

Closed

Description

Bug Report

TypeScript usually allows exporting values and types with the same name.

// a.ts
export const a = 1
export type a = string

But it doesn't work when re-exporting a type from a third-party library and exporting an arbitrary value at the same time.

// b.ts
export const a = 1
export type { a } from './a'  

🔎 Search Terms

export type re-export error

🕗 Version & Regression Information

  • Bug present in 4.1.3
  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about re-export

⏯ Playground Link

https://codesandbox.io/s/misty-field-16f9f?file=/src/index.ts

💻 Code

export type { A } from "./a";
export const A = Symbol("A");

🙁 Actual behavior

Error:

Cannot redeclare exported variable 'A'. ts(2323)

🙂 Expected behavior

I would expect this to work since the re-exported name is purely a type.

Activity

  1. DanielRosenwasser commented on Feb 4, 2021

    @DanielRosenwasser
    Member

    I think this is working as intended. Import/export aliases can't merge with local declarations in TypeScript. What's more, export type doesn't strictly import the type side of things, it only restricts the things you can do with that import to type-like positions, so even if we wanted to ease the restriction just for export type, we still couldn't.

    See

  2. paul-marechal commented on Feb 4, 2021

    @paul-marechal
    Author

    Import/export aliases can't merge with local declarations in TypeScript.

    Should this limitation on merging behavior be documented in the appropriate section of the official documentation?

  3. typescript-bot commented on Feb 7, 2021

    @typescript-bot
    Contributor

    This issue has been marked 'Working as Intended' and has seen no recent activity. It has been automatically closed for house-keeping purposes.

  4. locked as resolved and limited conversation to collaborators on Oct 21, 2025
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

    Working as IntendedThe behavior described is the intended behavior; this is not a bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions