microsoft / microsoft/TypeScript
`export { _void as void }` leads to exporting duplicate identifiers
- 主要语言
- Go
- 星标
- 111k
- 派生
- 14.3k
- 平均合并
- 2 天 4 小时
- 30 天内合并 PR
- 132
描述
### 🔎 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.
贡献指南
调研方向
先从提供的 tsconfig.json 和 schema.js 复现开始,然后检查 JavaScript 针对 export 列表的仅声明 emit。将生成的 schema.d.ts 与预期的 export 语句进行比较;当保留关键字 export 只出现一次,且没有不存在的标识符被 emit 时,即表示完成。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- javascript, typescript
- 领域
- compilers
- Issue 类型
- 缺陷
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 45/100