microsoft / microsoft/TypeScript
`export { _void as void }` leads to exporting duplicate identifiers
- Ngôn ngữ chính
- Go
- Star
- 111k
- Fork
- 14.3k
- Merge trung bình
- 2 ngày 4 giờ
- Pull request đã merge (30 ngày)
- 132
Mô tả
### 🔎 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.
Hướng dẫn đóng góp
Hướng nghiên cứu
Bắt đầu với tsconfig.json được cung cấp và bản tái hiện schema.js, sau đó kiểm tra quá trình chỉ emit declaration của JavaScript cho danh sách export. So sánh schema.d.ts được tạo với các câu lệnh export mong đợi; được xem là hoàn tất khi các export của từ khóa dành riêng chỉ xuất hiện một lần và không có định danh không tồn tại nào được emit.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- javascript, typescript
- Lĩnh vực
- compilers
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức phù hợp với người mới
- 45/100