zero-tolerance-doctrine: noImplicitAny reported missing when strict is true

Đang mở Phù hợp với người mới
#506 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

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

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
72/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
devtools

Hướng nghiên cứu

Kết quả false đến từ hai kiểm tra độc lập trên compilerOptions.strict và compilerOptions.noImplicitAny trong src/checkers/sacred-laws/zero-tolerance.ts, nên hãy bắt đầu từ đó. Đọc cách strict được xử lý trong kiểm tra hiện có, sau đó suy xét khi nào noImplicitAny chưa được đặt và khi nào nó được đặt tường minh là false. Hoàn thành khi một fixture có strict: true và không có noImplicitAny không tạo ra kết quả nào, còn fixture có strict: true, noImplicitAny: false vẫn tạo ra kết quả.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

Version: develop, and #503 (bugfix/486-foreign-json-reader)
Law: Zero Tolerance Doctrine (SACRED LAW): src/checkers/sacred-laws/zero-tolerance.ts

What happens

The law reports TypeScript noImplicitAny not enabled for a tsconfig that sets "strict": true and does not repeat "noImplicitAny": true. strict turns noImplicitAny on, so the finding is false.

develop, zero-tolerance.ts:

if (!tsConfig || !compilerOptions.strict) {
  violations.push('TypeScript strict mode not enabled');
}
if (!tsConfig || !compilerOptions.noImplicitAny) {
  violations.push('TypeScript noImplicitAny not enabled');
}

#503 reads the extends chain, but it keeps the same two independent checks (for (const [flag, finding] of [['strict', …], ['noImplicitAny', …]])).

Reproduction

A project whose tsconfig.json is { "compilerOptions": { "strict": true } } gets TypeScript noImplicitAny not enabled.

What I ruled out

This repository's own self-audit is not affected, because its tsconfig sets both flags explicitly. I have only read the code path above and have not built a fixture yet.

Suggested direction

Treat noImplicitAny as enabled when it is true, or when it is unset and strict is true. Only an explicit "noImplicitAny": false should be reported. strictModeOf in #503's src/utils/tsconfig-chain.ts already models this "strict implies" rule the other way round. Red/green: a fixture with strict: true and no noImplicitAny produces no finding, and one with strict: true, noImplicitAny: false still produces it.

Ngôn ngữ chính
TypeScript
Star
0
Fork
0
Merge trung bình
2 giờ 36 phút
Pull request đã merge (30 ngày)
168

Chuẩn bị môi trường

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.

Issue khác của Rule-Of-Code/RoC

Tất cả issue của Rule-Of-Code/RoC

Issue tương tự

Thêm issue về TypeScript

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.