javascript - 如何找到我的 typescript/react 模块的声明?
问题描述
我在前端技术方面非常(非常)新,特别是反应和打字稿。
当尝试做一个简单的事情是使用反应组件时,我的问题出现了https://github.com/ckeditor/ckeditor5
所以我去看了例子,发现了这个:
https://github.com/ckeditor/ckeditor5-react-example/blob/master/package.json
我正在尝试将ckeditor包含在ClassicEditor模块中
所以我在我的 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
我需要为打字稿导入模块定义(我猜)
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/ classiceditor 文件夹实际上存在 node_modules/@ckeditor/ckeditor5-editor-classic/src/classiceditor.js
知道我错过了什么吗?
解决方案
对于那些仍在寻找更好解决方案的人,我从Github找到了这个解决方案。
您需要创建文件./types/ckeditor/index.d.ts
并写入
declare module '@ckeditor/ckeditor5-react';
declare module '@ckeditor/ckeditor5-build-classic';
推荐阅读
- html - CSS:如何将子图像放在父背景图像前面?
- excel - VBA Implements / Inheritance
- r - 在 dplyr 中的 group_by 之后过滤组内的行
- c# - 尝试编写只读数据库 sqlite Wpf inno setup
- c# - 带有事件处理程序的 Autofac 单实例
- vb.net - ms-access "Great Than" 或相等查询
- google-bigquery - 从数组中删除空值/空值
- python - 批量归一化导致训练和推理损失之间的巨大差异
- c# - 将所有 POST 请求路由到 1 个接收 POST 正文的 APIController 方法
- c++ - 将数组传递给 lambda 函数