PreviewGroup declarations fail strict type checking with TS2430 in 1.10.1

未關閉 適合新手
#541 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
74/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
react, typescript
領域
frontend

研究方向

Issue 指出已發布的宣告 @rc-component/[email protected] PreviewGroup.d.ts,並提供一個啟用 strict 模式的最小 TypeScript 重現範例。安裝列出的相依套件並執行 npx tsc 命令以確認 TS2430,接著檢查 group 與共用 preview config 的宣告。完成條件是 strict 檢查通過,且 group 回呼仍可將 info.current 用作數字。

由索引模型根據 Issue 內容生成。

描述

PR #529 proposes a fix for this error. Here is a minimal reproduction using the published npm package.

Reproduction

In an empty directory:

npm init -y
npm install @rc-component/[email protected] react@18 react-dom@18
npm install -D [email protected] @types/[email protected] @types/react-dom@18
echo "import '@rc-component/image/es/PreviewGroup';" > index.ts
npx tsc --noEmit --strict --skipLibCheck false --target es2020 --module esnext --moduleResolution bundler index.ts
Actual result
PreviewGroup.d.ts(6,18): error TS2430: Interface 'GroupPreviewConfig' incorrectly extends interface 'InternalPreviewConfig'.
  Types of property 'imageRender' are incompatible.

The shared callback accepts info.current?: number, while the group callback requires info.current: number. The same error also reproduces with @types/[email protected].

Expected result

The published declarations should pass strict checking, and group callbacks should still be able to use info.current as a number.

主要語言
TypeScript
星號
211
分支
128
平均合併
2 天 23 小時
30 天內合併 PR
1

環境準備

這個專案沒有提供開發容器、Dockerfile 或貢獻指南,環境需要你自己搭建:先看它的 README,通用步驟見我們的新手貢獻指南。

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

react-component/image 的其他 Issue

查看 react-component/image 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。