microsoft / microsoft/TypeScript

Split the "lib.dom.d.ts" definition file apart

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

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

Needs Proposal Suggestion
Ngôn ngữ chính
Go
Star
111k
Fork
14.3k
Merge trung bình
1 ngày 19 giờ
Pull request đã merge (30 ngày)
117

Mô tả

Search Terms

lib.dom.d.ts, split, modular

Suggestion

I'm currently writing a TypeScript definition file for the API of a game, which will be submitted to DefinitelyTyped soon.

The API of the game exposes a Notification class to the global scope, which collides with the one in "lib.dom.d.ts" definition file. Not only that, but it also uses jQuery and XMLHttpRequest, forcing me to include that definition file.

Use Cases

By splitting the "lib.dom.d.ts" definition file apart, user can select only the APIs they need.

This change should not break the backward compatibility of old projects, although old versions of TypeScript will not support projects using the modular definition file.

Examples

For example, the "lib.dom.d.ts" definition file could be split up like this:

lib.dom.d.ts
|-- lib.dom.elements.d.ts
|-- lib.dom.notification.d.ts
|-- lib.dom.xhr.d.ts
`-- ... (other modules)

When some parts of the user's definition file collide with the "lib.dom.d.ts" definition file, the user can use the following instead:

{
    "compilerOptions": {
        "lib": [
            "DOM.Elements",
            "DOM.XHR",
            ... // (other modules except for "DOM.Notification")
        ]
        ...
    }
    ...
}

Checklist

My suggestion meets these guidelines:

  • This wouldn't be a breaking change in existing TypeScript/JavaScript code
  • This wouldn't change the runtime behavior of existing JavaScript code
  • This could be implemented without emitting different JS based on the types of the expressions
  • This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, etc.)
  • This feature would agree with the rest of TypeScript's Design Goals.

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

Bắt đầu bằng cách kiểm tra tệp định nghĩa lib.dom.d.ts hiện có và cách compilerOptions.lib chọn các định nghĩa thư viện. Xác định một cách phân chia theo mô-đun cho phép người dùng bỏ qua các API xung đột như DOM.Notification, đồng thời vẫn giữ nguyên hành vi hiện tại của lib.dom.d.ts đối với các dự án hiện có. Công việc được xem là hoàn tất khi tổ chức được đề xuất hỗ trợ các DOM API có thể lựa chọn mà không phá vỡ khả năng tương thích ngược.

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
Tính năng
Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
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
35/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.