microsoft / microsoft/TypeScript

No error when exporting from global augmentations

Đang mở
#64,152 0 bình luận 1 reaction 2 người được giao Xem trên GitHub

@DanielRosenwasser đang làm issue này rồi.

Từ ngày 4/9/2026.

  • #64162 của @copilot-swe-agent — đang mở
Breaking Change Bug
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ả

If you export a binding from the global scope, you're supposed to get an error unless you create a local binding and export it with whatever name you want.

```ts
export { Math };
// ~~~~
// Cannot export 'Math'. Only local declarations can be exported from a module.
```

However, we have a hole and allow exports that originate from a global augmentation. The following file is permitted with no error:

```ts
declare global {
var XYZ: number;
}

export { XYZ };
```

[Playground Link](https://www.typescriptlang.org/play/?#code/CYUwxgNghgTiAEBzCB7ARlC8DeAoeB8AbrPABoCaAWgFzwB2ArgLZogwDcuAvrriAA8ADihgAXHOWrxuHIA)

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.