microsoft / microsoft/TypeScript
In JS, reassignment of a constructor function should work.
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ả
graceful-fs allows the user to provide a constructor function for the ReadStream class. It then modifies the function’s prototype (including modifying its base class). If no function is provided, then it provides one. This pattern should be supported as long as the provided function is assignable to the default one.
// @noEmit: true
// @allowJs: true
// @checkJs: true
// @Filename: a.js
var fs = require('fs')
/** @type {{ a: () => void }} */
var legStreams
// from graceful-fs
function patch(process) {
if (process) {
ReadStream = legStreams.a
}
ReadStream.prototype = Object.create(fs.ReadStream)
ReadStream.prototype.open = fs$open
function ReadStream (path, options) {
if (this instanceof ReadStream) {
return fs.ReadStream.apply(this, arguments), this
}
else {
return ReadStream.apply(Object.create(ReadStream.prototype), arguments)
}
}
function fs$open() {
}
// ReadStream should still be newable too!
function createReadStream(path, options) {
return new ReadStream(path, options)
}
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 với bản tái hiện a.js trong issue và chạy nó với allowJs và checkJs được bật. Theo dõi cách các hàm constructor JavaScript được định kiểu khi ReadStream được gán lại, bao gồm cả lệnh gọi new ReadStream về sau. Hoàn thành khi bản tái hiện chấp nhận một constructor được gán lại có thể gán được, đồng thời vẫn giữ khả năng khởi tạo bằng new.
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
- Khá rõ ràng
- Mức phù hợp với người mới
- 35/100