Typings import `react` but `@types/react` is not declared as a peer dependency
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
- 62/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
- Lĩnh vực
- build-system, frontend
Hướng nghiên cứu
Bản sửa nằm trong package.json, nơi peerDependencies liệt kê react, react-dom và tinymce nhưng không có @types/react. Các khai báo kiểu đã xuất bản trong lib/es2015/main/ts/components/Editor.d.ts import từ react, đó là lý do cần khai báo này. Tái hiện lỗi với repo được liên kết bằng cách chạy pnpm install và pnpm typecheck, với enableGlobalVirtualStore đặt thành true. Hoàn thành khi peer tùy chọn @types/react đã được khai báo và kiểm tra kiểu chạy thành công với thiết lập đó.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
What is the current behavior?
The published typings import from react (for example lib/es2015/main/ts/components/Editor.d.ts), but package.json doesn't declare @types/react anywhere. The peer dependencies are only react, react-dom and tinymce.
This usually works by accident because @types/react is hoisted somewhere above the package in node_modules. It fails under package managers that only let a package see what it declares. With pnpm's global virtual store (enableGlobalVirtualStore: true), each package is linked from a shared directory outside the project, so TypeScript can't find @types/react from inside @tinymce/tinymce-react. Editor then stops typechecking as a React component:
src/App.tsx(4,10): error TS2607: JSX element class does not support attributes because it does not have a 'props' property.
src/App.tsx(4,11): error TS2786: 'Editor' cannot be used as a JSX component.
Its type 'typeof Editor' is not a valid JSX element type.
Type 'typeof Editor' is not assignable to type 'new (props: any, context: any) => Component<any, any, any>'.
Type 'Editor' is missing the following properties from type 'Component<any, any, any>': context, setState, forceUpdate, props, state
This is a different cause from https://github.com/tinymce/tinymce-react/issues/332. That issue was two mismatched @types/react versions, while here the package can't resolve @types/react at all.
Please provide the steps to reproduce and if possible a minimal demo of the problem via codesandbox.io or similar.
Minimal reproduction: https://github.com/joeymckenzie/tinymce-react-types-react-repro
pnpm install
pnpm typecheck
src/App.tsx is just:
import { Editor } from "@tinymce/tinymce-react";
export function App() {
return <Editor licenseKey="gpl" initialValue="<p>Hello</p>" />;
}
With the same lockfile and enableGlobalVirtualStore: false, tsc passes.
What is the expected behavior?
Editor typechecks without relying on @types/react being hoisted. Declaring it as an optional peer would do that and keep sharing the consumer's copy:
"peerDependencies": {
"@types/react": "^19.0.0 || ^18.0.0 || ^17.0.0 || ^16.7.0"
},
"peerDependenciesMeta": {
"@types/react": { "optional": true }
}
Our workaround in the meantime is declaring it on the package's behalf in pnpm-workspace.yaml:
packageExtensions:
"@tinymce/tinymce-react":
peerDependencies:
"@types/react": "*"
peerDependenciesMeta:
"@types/react":
optional: true
Which versions of TinyMCE, and which browser / OS are affected by this issue? Did this work in previous versions of TinyMCE or tinymce-react?
@tinymce/tinymce-react 6.3.0
- Ngôn ngữ chính
- TypeScript
- Star
- 1.1k
- Fork
- 167
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc 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.
Issue khác của tinymce/tinymce-react
-
smart_paste doesn't detected pasted urls as linkCó thể đã có người làm @hardikpedia đã nhận 50 ngày trước. Đang mởstatus: escalated
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 55/100
tinymce/tinymce-react#611 · 1 bình luận ·
-
needs: more info
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 20/100
tinymce/tinymce-react#595 · 1 bình luận ·
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
tinymce/tinymce-react#587 · 15 bình luận · 3 reaction ·
-
GitHub status: escalated
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 25/100
tinymce/tinymce-react#501 · 5 bình luận · 8 reaction ·
-
bug GitHub status: escalated
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
tinymce/tinymce-react#403 · 5 bình luận · 1 reaction ·
Tất cả issue của tinymce/tinymce-react
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
tenstorrent/ttnn-visualizer#2526 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
trySessionCache calls /get-session twice when minting session_data (cache miss or expired cookie)Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
neondatabase/neon-js#301 ·
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
tashfeenahmed/freellmapi#2305 ·
Maintainer thường phản hồi trong vòng 1 ngày