Typings import `react` but `@types/react` is not declared as a peer dependency
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Facilidade para iniciantes
- 62/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- react, typescript
- Domínio
- build-system, frontend
Direção de pesquisa
A correção está em package.json, onde peerDependencies lista react, react-dom e tinymce, mas não @types/react. As tipagens publicadas em lib/es2015/main/ts/components/Editor.d.ts importam de react, por isso a declaração é necessária. Reproduza com o repositório vinculado usando pnpm install e pnpm typecheck, com enableGlobalVirtualStore definido como true. Está concluído quando a peer opcional @types/react estiver declarada e a verificação de tipos passar com essa configuração.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
- Linguagem predominante
- TypeScript
- Estrelas
- 1.1k
- Forks
- 167
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Tem um modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de tinymce/tinymce-react
-
smart_paste doesn't detected pasted urls as linkTalvez já em andamento @hardikpedia assumiu há 50 dias. Abertastatus: escalated
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 55/100
tinymce/tinymce-react#611 · 1 comentário ·
-
needs: more info
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 20/100
tinymce/tinymce-react#595 · 1 comentário ·
-
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 35/100
tinymce/tinymce-react#587 · 15 comentários · 3 reações ·
-
GitHub status: escalated
Dificuldade 3/5 1-2 dias Facilidade para iniciantes 25/100
tinymce/tinymce-react#501 · 5 comentários · 8 reações ·
-
bug GitHub status: escalated
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
tinymce/tinymce-react#403 · 5 comentários · 1 reação ·
Todas as issues de tinymce/tinymce-react
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
zabuton-app/meguri#875 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 86/100
iruzen-dono/workless#117 ·
Mantenedores costumam responder em até 1 dia
-
area:api area:web wave wave:trivial
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 67/100
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
Mantenedores costumam responder em até 1 dia
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
vetro-protocol/vetro-monorepo#1321 ·
Mantenedores costumam responder em até 1 dia