microsoft / microsoft/TypeScript
Suggestion: Support readonly interfaces in `getSuggestedLibFor...`
Chưa có ai nhận issue này.
- 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
readonly target library
### ✅ Viability Checklist
- [x] This wouldn't be a breaking change in existing TypeScript/JavaScript code
- [x] This wouldn't change the runtime behavior of existing JavaScript code
- [x] This could be implemented without emitting different JS based on the types of the expressions
- [x] This isn't a runtime feature (e.g. library functionality, non-ECMAScript syntax with JavaScript output, new syntax sugar for JS, etc.)
- [x] This isn't a request to add a new utility type: https://github.com/microsoft/TypeScript/wiki/No-New-Utility-Types
- [x] This feature would agree with the rest of our Design Goals: https://github.com/Microsoft/TypeScript/wiki/TypeScript-Design-Goals
### ⭐ Suggestion
Read-only variants of ECMAScript interfaces are currently not eligible for script target suggestions. This is most noticeable with `ReadonlyArray`, since this type can arise through syntax rather than by referencing the symbol directly.
```ts
[1,2,3].toReversed();
// ~~~~~~~~~~
// Property 'toReversed' does not exist on type 'number[]'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2023' or later.
([1,2,3] as const).toReversed();
// ~~~~~~~~~~
// Property 'toReversed' does not exist on type 'readonly [1, 2, 3]'.
```
It would be useful if the suggested lib checks could resolve these in the same way.
### 📃 Motivating Example
As above.
### 💻 Use Cases
N/A
Hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- 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 lần theo các kiểm tra getSuggestedLibFor... hiện có và các bài kiểm thử của chúng, sau đó so sánh cách các biểu thức mảng mutable và readonly được phân giải. Sử dụng các ví dụ toReversed đã được báo cáo làm các trường hợp chấp nhận; hoàn tất nghĩa là cả hai dạng đều đề xuất thư viện đích phù hợp mà không thay đổi hành vi runtime.
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ó
- 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
- 48/100