Skip to content

export * as X cannot be imported when type X is exported #44896

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Conaclos opened this issue Jul 4, 2021 · 0 comments · Fixed by #50853
Closed

export * as X cannot be imported when type X is exported #44896

Conaclos opened this issue Jul 4, 2021 · 0 comments · Fixed by #50853
Assignees
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue

Comments

@Conaclos
Copy link

Conaclos commented Jul 4, 2021

Bug Report

🔎 Search Terms

  • star-export
  • impossible value import
  • namespace identifier
  • type value export

Is kinda related to #36704 and #41409.

🕗 Version & Regression Information

I test on typescript@latest and typescript@next at the moment of writing.

  • This is the behavior in every version I tried, and I reviewed the FAQ for entries about type-value exports

⏯ Playground Link

TypeScript Playground

💻 Code

// @strict

// @filename: constants.ts
export const COFFEE = 0;
export const TEA = 1;


// @filename: drink.ts
export type Drink = 0 | 1;
export * as Drink from "./constants";


// @filename: index.ts
import { Drink } from "./drink";
// 'Drink' only refers to a type, but is being used as a value here
const x: Drink = Drink.TEA;

🙁 Actual behavior

According to TS Drink is not imported as a value.

🙂 Expected behavior

No error should occur.

I'm currently using the following workaround:

// @strict

// @filename: constants.ts
export const COFFEE = 0;
export const TEA = 1;


// @filename: drink.ts
import * as DrinkConstants from "./constants";
export type Drink = 0 | 1;
export const Drink = DrinkConstants;


// @filename: index.ts
import { Drink } from "./drink";
const x: Drink = Drink.TEA;
@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Jul 6, 2021
@typescript-bot typescript-bot added the Fix Available A PR has been opened for this issue label Sep 19, 2022
@andrewbranch andrewbranch added this to the TypeScript 4.9.0 milestone Sep 20, 2022
@andrewbranch andrewbranch added Bug A bug in TypeScript and removed Needs Investigation This issue needs a team member to investigate its status. labels Sep 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants