microsoft / microsoft/TypeScript

Module is present in declarations even though it is unused.

Open
#55,571 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: Declaration Emit
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
1d 19h
Merged PRs (30d)
117

Description

🔎 Search Terms

module unused declarations

🕗 Version & Regression Information
  • This is the behavior in every version I tried, and I reviewed the FAQ
⏯ Playground Link

https://www.typescriptlang.org/play?ts=5.2.2#code/KYDwDg9gTgLgBAbwL4CgAmwDGAbAhlYOAWwjQFdtCS0BGRFORuUSWOGATzEJmAGcYdALxwBUAJYA7AOYBuFKgw58VUhVVoATPSZxxRVvF4DhxUjQB0xwfN0to8BO36C4SeUiA

💻 Code
export {}
declare module mod1 {
    export type test1 = string;
}
declare module mod2 {
    import test1 = mod1.test1;
    export { test1 };
}
🙁 Actual behavior

mod1 is kept in the declaration.

🙂 Expected behavior

mod1 is not kept in the declaration file since it is only used in mod2 which is omitted from the declaration file.

Additional information about the issue

Found while working on isolated declarations in test reExportAliasMakesInstantiated.ts added by #54816 (cc @andrewbranch )

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

Reproduce the behavior with the linked TypeScript Playground example, then read the isolated-declarations test reExportAliasMakesInstantiated.ts mentioned in the issue and compare its emitted declaration output. Done means the unused mod1 declaration is omitted when mod2 itself is omitted from the declaration file, with the relevant test covering the behavior.

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
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.