Support for ECMA Script import
See original GitHub issueHi, first of all, ngraph is a great project!
Maybe I’m overworked but trying to import ngraph.graph in my TypeScript project I’m not successfull:
import createGraph from 'ngraph.graph'
cause TypeError: createGraph.default is not a function
import { createGraph } from 'ngraph.graph'
cause Module '"ngraph.graph"' has no exported member 'createGraph'.
Am I doing something wrong or I missed something? Couldn’t find any solution on the web 😦
Issue Analytics
- State:
- Created a year ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
ECMAScript modules | Node.js v19.3.0 Documentation
Node.js fully supports ECMAScript modules as they are currently specified and provides ... Dynamic import() is supported in both CommonJS and ES modules....
Read more >import - JavaScript - MDN Web Docs - Mozilla
If an import declaration is encountered in non-module contexts (for example, <script> tags without type="module" , eval , new Function , which ...
Read more >Announcing core Node.js support for ECMAScript modules
Node.js 13.2.0 ships support for ECMAScript modules, known for their import and export statements. This support was previously behind ...
Read more >Documentation - ECMAScript Modules in Node.js - TypeScript
Node.js supports a new setting in package.json called type . ... When a .ts file is compiled as an ES module, ECMAScript import...
Read more >ECMAScript Modules - Jest
Jest ships with experimental support for ECMAScript Modules (ESM). ... If your codebase includes ESM imports from *.wasm files, you do not ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I found a solution. Adding
"esModuleInterop": true
in tsconfig.json do the trick. See https://www.typescriptlang.org/tsconfig#esModuleInteropIt would be maybe very nice to support your project by defining types on
npm @types/ngraph.graph
. Other libraries, such ngraph.from/todot would be typed as well… It’s very nice and usefull project and going accross the development in TypeScript can spread its use I guess.