SinglePickerPanelProps incorrectly extends BasePickerPanelProps under exactOptionalPropertyTypes

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

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
78/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ệ
react, typescript

Hướng nghiên cứu

Bắt đầu với khai báo trong lib/PickerPanel/index.d.ts và kiểm tra cách SinglePickerPanelProps kế thừa BasePickerPanelProps cũng như khai báo defaultValue. Áp dụng thay đổi chỉ dành cho kiểu dữ liệu mà issue đề xuất, sau đó chạy tsc --noEmit với strict và exactOptionalPropertyTypes được bật, còn skipLibCheck bị tắt. Hoàn tất khi các khai báo của package biên dịch mà không có TS2430 và props vẫn không thay đổi đối với người dùng không bật cờ đó.

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

Mô tả

Summary

rc-picker 4.11.3, with TypeScript 7.0.2, "strict": true, "exactOptionalPropertyTypes": true, "skipLibCheck": false: its declarations report errors themselves (no error in user code is needed).

lib/PickerPanel/index.d.ts TS2430: Interface 'SinglePickerPanelProps' incorrectly extends interface 'BasePickerPanelProps'. Types of property 'defaultValue' are incompatible: it is redeclared as DateType | null over the inherited SharedTimeProps.defaultValue?: DateType.

Repro
{ "compilerOptions": { "strict": true, "exactOptionalPropertyTypes": true, "skipLibCheck": false,
  "jsx": "react-jsx", "module": "esnext", "moduleResolution": "bundler", "noEmit": true } }

Import the package (or the antd 5 component that uses it) and run tsc --noEmit.

Fix (type-only; identical for consumers without the flag)

export interface SinglePickerPanelProps<DateType extends object = any> extends Omit<BasePickerPanelProps<DateType>, 'defaultValue'>. The resulting props are unchanged, since the interface redeclares defaultValue itself.

We run this as a local patch with no other changes. Happy to open a PR.

Ngôn ngữ chính
TypeScript
Star
306
Fork
356
Merge trung bình
1 giờ 42 phút
Pull request đã merge (30 ngày)
1

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

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

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 react-component/picker

Tất cả issue của react-component/picker

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.