Bug: Type aliases referenced inside index signatures results in an invalid .d.ts file
- Dominant language
- TypeScript
- Stars
- 11.3k
- Forks
- 275
- PR merge metrics
- No merged PRs in 30d
Description
Hi! I've run into a bit of a bug with the bundling of .d.ts files. This was brought to my attention in an issue [here](https://github.com/airjp73/remix-validated-form/issues/227).
## Description
Bundling the following code outputs an invalid .d.ts file.
Input:
```ts
type Foo = string;
export type TestType = {
[key: `__${Foo}`]: any;
};
```
Output:
```ts
type TestType = {
[key: `__${Foo}`]: any;
};
export { TestType };
```
The output is missing the `Foo` type.
If you were to add `export type Bar = Foo` to the input, that would fix it and correctly include the `Foo` type in the .d.ts file.
## Reproduction repo
https://github.com/airjp73/index-type-error
Contributor guide
Research direction
Start with the linked reproduction repository and compare the generated declaration output for the provided index-signature example. Trace the declaration bundling entry point that omits the non-exported Foo alias, then confirm the fix produces a valid .d.ts file containing Foo without requiring an additional exported alias.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100