如何找到我的 typescript/react 模块的声明?

2024-05-05

我对前端技术非常(非常)陌生,特别是 React 和 TypeScript。

当尝试做一件简单的事情,即使用反应组件时,我的问题出现了https://github.com/ckeditor/ckeditor5 https://github.com/ckeditor/ckeditor5

所以我查看了示例并发现了这一点:

https://github.com/ckeditor/ckeditor5-react-example/blob/master/package.json https://github.com/ckeditor/ckeditor5-react-example/blob/master/package.json

我正在尝试包括ckeditor经典编辑器 module

所以我将其添加到我的 package.json 中

"@ckeditor/ckeditor5-editor-classic": "^12.0.0",
"@ckeditor/ckeditor5-essentials": "^11.0.0",
"@ckeditor/ckeditor5-paragraph": "^11.0.0",
"@ckeditor/ckeditor5-react": "^1.1.2",

并在此处检查实施情况https://github.com/ckeditor/ckeditor5-react-example/blob/master/src/App.js https://github.com/ckeditor/ckeditor5-react-example/blob/master/src/App.js

我需要导入打字稿的模块定义(我猜)

import CKEditor from '@ckeditor/ckeditor5-react';

// NOTE: We use editor from source (not a build)!
import ClassicEditor from '@ckeditor/ckeditor5-editor-classic/src/classiceditor';

所以,这部分有这个奇怪的注释,但碰巧在我的项目中不起作用(说丢失并且找不到它)

知道我还能做什么来添加它吗?我尝试删除/src/classiceditor部分但仍然失踪​​。

我制造了一个npm install我可以看到包含 package.json 的 classiceditor 代码等等.../src/经典编辑器文件夹实际上存在node_modules/@ckeditor/ckeditor5-editor-classic/src/classiceditor.js

知道我缺少什么吗?


对于那些仍在寻找更好解决方案的人,我找到了这个解决方案Github https://github.com/ckeditor/ckeditor5-react/issues/140#issuecomment-655453105.

你需要创建文件./types/ckeditor/index.d.ts并写信给

declare module '@ckeditor/ckeditor5-react';
declare module '@ckeditor/ckeditor5-build-classic';
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

如何找到我的 typescript/react 模块的声明? 的相关文章

随机推荐