microsoft / microsoft/TypeScript

`export as namespace` still allows access via properties in module files

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

Chưa có ai nhận issue này.

Bug Domain: ES Modules
Ngôn ngữ chính
Go
Star
111k
Fork
14.4k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Mô tả

TypeScript Version: 3.8.0-dev.20200119

Search Terms: export as namespace

Code

someModule.d.ts:

export function foo (bar: string): void;
export as namespace someModule;

index.ts:

import { foo } from './someModule';

someModule.foo;
window.someModule.foo;
globalThis.someModule.foo;

Expected behavior:

All of the attempts to access someModule as a global namespace in index.ts should result in compile-time errors, as index.ts is not a script file.

Actual behavior:

window.someModule.foo and globalThis.someModule.foo do NOT result in compile-time errors.

Playground Link: N/A (requires multiple files)

Related Issues: None found

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.

Hướng nghiên cứu

Tái hiện vấn đề với hai tệp được hiển thị, someModule.d.ts và index.ts, bằng cách sử dụng phiên bản TypeScript được báo cáo hoặc một build hiện tại. So sánh các chẩn đoán đối với quyền truy cập trực tiếp, qua window và qua globalThis, sau đó theo dõi cách trình biên dịch xử lý export as namespace. Hoàn tất khi cả ba quyền truy cập vào global namespace trong tệp module đều tạo ra lỗi tại thời điểm biên dịch.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
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
Khá rõ ràng
Mức phù hợp với người mới
42/100

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.