I have a Visual Studio code extension that has been developed in TypeScript and I would like to know if there is a way to reference methods from a DLL using Typescript. In this scenario, the DLL has logic to tokenize various elements in markdown files and I would like to leverage this logic instead of rewriting it.
I've used a library called ctypes for similar work in Python and I was wondering if anyone knows of a module for TypeScript or any native TypeScript functionality that I can leverage.
Thanks in advance for any pointers.
This isn't a TypeScript specific problem. It's more broadly a JavaScript one.
Take a look at edge—specifically the section titled "How to: integrate c# code into Node.js code".
Using that you can load a .net assembly like so (code is lifted from their readme):
var clrMethod = edge.func({
assemblyFile: 'My.Edge.Samples.dll',
typeName: 'Samples.FooBar.MyType',
methodName: 'MyMethod' // This must be Func<object,Task<object>>
});
If you're not using a .net assembly then you might be able to create a wrapper in .net to that library then reference that .net assembly in edge, but I'm not sure if that would work.
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