I am working with an npm module (node-rsa), trying to use typescript. In the example for my module, I need to write some js like this (taken from the module docs).
var NodeRSA = require('node-rsa');
var key = new NodeRSA({b: 512});
However, when I type this in TypeScript:
import {NodeRSA} from 'node-rsa';
var key = new NodeRSA({b: 512});
it compiles to:
var node_rsa_1 = require('node-rsa');
var key = new node_rsa_1.NodeRSA({ b: 512 });
which throws the error:
"node_rsa_1.NodeRSA is not a function"
I am having to write my own .d.ts file, as there is nothing on DT, so I am not sure if that makes any difference?
I tried this on my project and it worked:
import * as NodeRSA from 'node-rsa';
I think that's because node-rsa has a default export.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With