Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

165
Views
import JavaScript module in angular nx project

I have an angular project built with nx I want to import standard JavaScript libraries which do not have typescript typings for example I want to install and use cytoscape and cytoscape-context-menus

I get compilation errors such as

error TS7016: Could not find a declaration file for module 'cytoscape-context-menus'. 'C:/dev/armo/armo-ng-app/node_modules/cytoscape-context-menus/cytoscape-context-menus.js' implicitly has an 'any' type. Try npm i --save-dev @types/cytoscape-context-menus if it exists or add a new declaration (.d.ts) file containing declare module 'cytoscape-context-menus';

How can I solve them? I tried to put declaration files but I think my setup doesn't see them.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

since there's no available type definition npm package, you have to write your own. start with the ones you need and continue to build on top of it as needed.

if you like you can share it too as an npm package.

found this article for writing TypeScript type definition files by @dubtypescript: http://blog.wolksoftware.com/contributing-to-definitelytyped

also take a look at how cytoscope is typed from here, borrow their ways: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/cytoscape/index.d.ts

Added a stackblitz to checkout:

https://stackblitz.com/edit/cytoscape-6cyuem?file=src%2Fapp%2Fcytoscape-context-menus.d.ts

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!