Error when trying to resolve augmented modules via `--dts-only` and `--dts-resolve`
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
## Problem
- When trying to generate DTS files for a specific module that depends on another module having it's types declared via module augmentation (`declare module ...`) results in an error.
- However, TypeScript compiler is able to resolve augmented modules.
## Version info
- tsup 8.3.0
- typescript 5.6.3
## Repro
1. Create a new package called `tsup-augmented-module` via `npm init` and put inside `index.d.ts` module augmentation, e.g.:
```
declare module "tsup-augmented-module" {
export type SetupOptions = {
token: string;
someOtherOption?: number;
};
}
```
2. Specify `"types": "index.d.ts"` in `package.json`.
3. Create another consumer module via `npm init` and put your augmented module as dependency:
```
"dependencies": {
"tsup-augmented-module": "file:../tsup-augmented-module",
}
```
4. Now, in your `index.ts` write:
```
import { SetupOptions } from 'tsup-augmented-module';
export function test(options: SetupOptions): string {
return 'test accomplished!';
}
```
5. Now, run `npx tsup --entry index.ts --dts-only --dts-resolve ` and see an error like:
```
RollupError: "SetupOptions" is not exported by 'tsup-augmented-module', imported by "./index.ts".
```
## Expectation
As typescript complier is able to resolve augmented modules, `tsup` should be able to as well.
Contributor guide
Research direction
Reproduce the issue with the augmented package's package.json and index.d.ts, the consumer's index.ts, and `npx tsup --entry index.ts --dts-only --dts-resolve`. Trace how declaration resolution handles the `declare module` export, then verify that the command resolves `SetupOptions` and emits declarations without the RollupError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rollup, typescript
- Domain
- build-system, developer-experience
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100