Skip to content

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

Closed
@paul-marechal

Description

@paul-marechal

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.

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