microsoft / microsoft/TypeScript

Reduce amount of code necessary to quickly format the diagnostics to a string

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

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

Awaiting More Feedback Suggestion
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

FormatDiagnosticsHost

Suggestion

Often when someone is working with the TypeScript compiler API their type checker might have diagnostics. It would be useful for people to quickly check them by typing:

ts.formatDiagnostics(ts.getPreEmitDiagnostics(program))

Instead of:

ts.formatDiagnostics(ts.getPreEmitDiagnostics(program), {
    getCurrentDirectory: () => ts.sys.getCurrentDirectory(),
    getCanonicalFileName: f => f,
    getNewLine: () => "\n"
})

Possible solution is to make providing FormatDiagnosticsHost optional or add a default FormatDiagnosticsHost that people can use (or both).

Also for ts.formatDiagnostic and ts.formatDiagnosticsWithColorAndContext

Use Cases

Easier for people to quickly check the diagnostics while they're developing with the compiler API.

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.

Related Issues

#29581

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 với các entry point của TypeScript compiler API là formatDiagnostics, formatDiagnostic và formatDiagnosticsWithColorAndContext, sau đó theo dõi cách FormatDiagnosticsHost hiện đang được yêu cầu. So sánh các cách tiếp cận host tùy chọn và host mặc định được đề xuất, đồng thời giữ nguyên các lệnh gọi hiện có. Được xem là hoàn tất khi diagnostics có thể được định dạng nhanh chóng mà không cần truyền host và hành vi hiện tại không thay đổi.

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
api, 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
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.