Skip to content

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

Closed
@Conaclos

Description

@Conaclos

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;

Metadata

Metadata

Assignees

Labels

BugA bug in TypeScriptFix AvailableA PR has been opened for this issue

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions