microsoft / microsoft/TypeScript

TS:1379 An import alias cannot reference a declaration that was exported using 'export type'

Open
#54,855 12 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: ES Modules Help Wanted
Dominant language
Go
Stars
111k
Forks
14.4k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

Bug Report

🔎 Search Terms

TS1379
An import alias cannot reference a declaration that was exported using 'export type'

🕗 Version & Regression Information

This has always been the behavior as far as I can tell (edit: tested on all versions listed in playground back to >3.7.5 (changed to export type {...} statement when needed))

⏯ Playground Link

Multi file: repro but I will show in playground.

Below are pictures that might be easier to parse

💻 Code

When annotated with type it errors
Screen Shot 2023-07-01 at 10 29 21 AM

Screen Shot 2023-07-01 at 10 30 29 AM

When not annotated with type it doesn't error:
Screen Shot 2023-07-01 at 10 31 27 AM

Screen Shot 2023-07-01 at 10 31 41 AM
🙁 Actual behavior

Exports of types annotated with type error while those not annotated as types do not error even though TS understand it is still a type.

🙂 Expected behavior

Honestly I don't know which of these behaviors is correct - this behavior could be completely intentional as well - intuitively I think these should match and I prefer the behavior with no errors but it is unclear to me if this is an emit issue? I'm sorry if this behavior is on purpose and I have wasted your time. Really appreciate the work!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked multi-file TypeScript Playground reproduction and compare the annotated and unannotated import-alias cases that produce TS1379. First determine whether the differing diagnostics are intentional or an emit/type-checking defect; done means the expected behavior is established and covered by an appropriate regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.