Typings import `react` but `@types/react` is not declared as a peer dependency
まだ誰も着手していません。
評価
- 難易度
- 2/5
- 見積もり時間
- 1〜3時間
- 初心者へのやさしさ
- 62/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- react, typescript
- 領域
- build-system, frontend
調査の方向性
修正対象は package.json です。そこでは peerDependencies に react、react-dom、tinymce は記載されていますが、@types/react は記載されていません。公開されている型定義 lib/es2015/main/ts/components/Editor.d.ts は react からインポートしているため、この宣言が必要です。リンク先のリポジトリで pnpm install と pnpm typecheck を実行し、enableGlobalVirtualStore を true に設定して再現してください。オプショナルな peer である @types/react が宣言され、この設定のもとで typecheck が通れば完了です。
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- TypeScript
- スター
- 1.1k
- フォーク
- 167
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
tinymce/tinymce-react のほかの issue
-
smart_paste doesn't detected pasted urls as link対応中かも @hardikpedia が 50 日前に担当しました。 オープンstatus: escalated
難易度 3/5 1〜2日 初心者へのやさしさ 55/100
tinymce/tinymce-react#611 · コメント 1 件 ·
-
needs: more info
難易度 4/5 3〜5日 初心者へのやさしさ 20/100
tinymce/tinymce-react#595 · コメント 1 件 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 35/100
tinymce/tinymce-react#587 · コメント 15 件 · リアクション 3 件 ·
-
GitHub status: escalated
難易度 3/5 1〜2日 初心者へのやさしさ 25/100
tinymce/tinymce-react#501 · コメント 5 件 · リアクション 8 件 ·
-
bug GitHub status: escalated
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
tinymce/tinymce-react#403 · コメント 5 件 · リアクション 1 件 ·
tinymce/tinymce-react の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
zabuton-app/meguri#875 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 86/100
iruzen-dono/workless#117 ·
メンテナーはふだん 1 日以内に返信
-
area:api area:web wave wave:trivial
難易度 2/5 1〜3時間 初心者へのやさしさ 67/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
vetro-protocol/vetro-monorepo#1321 ·
メンテナーはふだん 1 日以内に返信