microsoft / microsoft/TypeScript
Ignore Specific Error [AGAIN]
Chưa có ai nhận issue này.
- 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ả
Yes, this is a duplicate of #11051, but that issue is closed and this NEEDS to be addressed.
People use Typescript for more than just Javascript compilation now. There are tons of transpilers that convert TS to all sorts of useful languages. Typescript must have a proper way to disable certain error codes project-wide.
My specific issue right now is that I'm using TypescriptToLua, a Typescript transpiler that produces lua code, and Typescript throws a fit whenever I try to use mathematical operators on classes. This would make sense if I was compiling to Javascript, but I'm not, but I'm forced to annotate every line with @ts-ignore (unrealistic) or suffer through constant reports of TS2362 and TS2363 in my console (infuriating).
There could easily be an ignoreErrors: number[] in the .tsconfig file that provides this functionality. The only thing stopping it from existing is stubborness. Well designed errors that never cause issues are a nice dream, but realistically there will always be use cases that are not met by the error handler, and the user should have the power to suppress invalid warnings.
A short example of my issue:
Typescript that will be converted using TypescriptToLua:
/** @customConstructor vector.new */
declare class Vector {
constructor(x: number, y?: number, z?: number);
}
const v = new Vector(1, 2, 3);
const vSquared = v * v;
Generated (valid) lua code:
--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
v = vector.new(1, 2, 3)
vSquared = v * v
Obnoxious compiler output:
main.ts:9:18 - error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
9 const vSquared = v * v;
~
main.ts:9:22 - error TS2363: The right-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type.
9 const vSquared = v * v;
~
Thank you for your time, I hope that this issue can be seen as what is is, which is a frustrating lack of user control and agency.
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
Xem xét các tùy chọn trình biên dịch tsconfig của TypeScript và cách xử lý chẩn đoán, bắt đầu với việc yêu cầu tắt chẩn đoán TS2362 và TS2363 trên toàn bộ dự án. So sánh với issue trùng lặp đã đóng #11051; được xem là hoàn tất khi xác định và triển khai một cơ chế cấu hình đã được thống nhất để tắt các mã chẩn đoán được chọn mà không yêu cầu @ts-ignore cho từng dòng.
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
- 25/100