typescript - 如何在 TypeScript 中使用 Cytoscape.Js 扩展?
问题描述
我尝试在 Typescript 项目中使用带有扩展名的 CytoscapeJS - Cytoscape-Node-Editing 。参考this Q&A后,我更改了一行@types/cytoscape
index.d.ts
但是,由于我不熟悉它,我在黑暗中迷失了设置,所以想得到任何建议,如何实施?还是其他地方有问题?真挚地。
@types/cytoscape/index.d.ts
function use(module: Ext, module2?: Ext, module3?: Ext): void;
画布.ts
import cytoscape from "cytoscape";
import $ from 'jquery';
import Konva from 'konva';
import nodeEditing from "cytoscape-node-editing";
cytoscape.use(nodeEditing, Konva, $);
var cy = (window.cy = cytoscape({
...
})
cy.nodeEditing();
然后收到错误消息
Argument of type 'typeof Konva' is not assignable to parameter of type 'Ext'.
Type 'typeof Konva' provides no match for the signature '(cytoscape: (options?: CytoscapeOptions | undefined) => Core): void'.
解决方案
根据使用说明:https ://github.com/iVis-at-Bilkent/cytoscape.js-node-editing您的代码应该更像这样:
import cytoscape from 'cytoscape';
import $ from 'jQuery';
import nodeEditing from 'cytoscape-node-editing';
import konva from 'konva';
nodeEditing( cytoscape, $, konva ); // register extension
我对 cytoscape 不熟悉,但很少需要弄乱.d.ts
@types/packages 包含的文件。有什么我想念的吗?
推荐阅读
- javascript - 检查数字的最后一位
- ruby - Rails 5x 模型购物车实例,必须链接到用户
- html - 无法在 cdk-virtual-scroll-viewport 中删除 mat-horizontal 步进导航
- c# - Sharepoint开发,splistitemcollection
- javascript - Firebase Javascript 从数据库读取并将每个键插入 HTML
- sql-server - SQL Server 几何。STPointN(2) - STX 和 STY 值
- apache-spark - 从火花桶中检索数据
- python - for循环中的Python pandas read_csv .txt文件不返回任何元素
- docker - 如何卸载 Docker 映像
- git - 错误:RPC 失败;curl 56 GnuTLS recv 错误(-12):已收到 TLS 致命警报。Ubuntu