microsoft / microsoft/TypeScript

`export { _void as void }` leads to exporting duplicate identifiers

Open
#62,081 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Domain: Declaration Emit Help Wanted
Dominant language
Go
Stars
111k
Forks
14.3k
Avg merge
2d 4h
Merged PRs (30d)
132

Description

### 🔎 Search Terms

`export void` `export reserved` `export null`

### 🕗 Version & Regression Information

- Reproducible since typescript v4. In older releases, it doesn't export anything. I also tried the latest dev release (5.9.0-dev.20250716)
- This is the behavior in every version I tried, and I reviewed the FAQ for entries about `exports`

### ⏯ Playground Link

[Playground (important: lang:javascript)](https://www.typescriptlang.org/play/?target=99&jsx=0&filetype=js#code/FAUwHgDg9gTgLgAgMZQHYGdEH0BuUCWAJggLwIDeAvsKJLIuQrgcQIboJ5EKUI1A)

### 💻 Code
Using the following `tsconfig.json`:

```json
{
"compilerOptions": {
"target": "esnext",
"lib": ["esnext"],
"module": "esnext",
"allowJs": true,
"checkJs": true,
"declaration": true,
"declarationMap": true,
"outDir": "./dist",
"emitDeclarationOnly": true,
"strict": true,
"noImplicitAny": true,
"moduleResolution": "bundler"
}
}
```

I compile declaration files for this code `${project}/schema.js` (only happens when compiling javascript):

```ts
const _null = {}
const $void = {}

export { _null as null, $void as void }
```

### 🙁 Actual behavior

The produced declaration file `schema.d.ts` is erroneous. It has duplicate identifiers:

```ts
declare const _null: {};
declare const $void: {};
export { _null as null, _null as null, $void as void, _void as void };
```

### 🙂 Expected behavior

No duplicate identifiers:

```ts
declare const _null: {};
declare const $void: {};
export { _null as null, $void as void };
```

### Additional information about the issue

For any reserved keyword, `tsc` always exports `_{reserved} as {reserved}`, whenever `{reserved}` is exported. Even though the variable `_{reserved}` does not exist.

It is only reproducible when compiling javascript.

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 provided tsconfig.json and schema.js reproduction, then inspect JavaScript declaration-only emit for the export list. Compare the generated schema.d.ts with the expected export statements; done means reserved-keyword exports appear once and no nonexistent identifiers are emitted.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.