Is it possible to use Cytoscape UI extensions in Typescript? I am able to use the Layout extension, but when I try to implement other extensions like https://github.com/cytoscape/cytoscape.js-cxtmenu, I encounter issues as the function cy.cxtmenu( defaults ) is not part of the cytoscape interface. Is there a workaround for this?
Here is the code snippet from my index.ts file:
import cytoscape = require('cytoscape');
import contextMenus = require('cytoscape-cxtmenu');
cytoscape.use(contextMenus);
const cy = cytoscape({
container: document.getElementById('cy'),
...
});
let defaults = {
menuRadius: 100,
selector: 'node',
//...
};
let menu = cy.cxtmenu( defaults );
I have added the following declaration to index.d.ts:
declare module 'cytoscape-cxtmenu' {
const ext: cytoscape.Ext;
export = ext;
}
However, during transpilation, I receive the following error in the console:
ERROR in [at-loader] ./src/index.ts:152:17
TS2339: Property 'cxtmenu' does not exist on type 'Core'.