0
votes

I'm trying to import Typescript typings for node-soap.

I need to access an WSDL API from a React app with Typescript. The node-soap module looks like a great option, but I need Typescript support. On the node-soap github, I see a file with all the Typescript typings, but I don't know how to import them. I copied "soap.d.ts" into the node_modules/node-soap directory, but VSCode still says I need to declare the module. I'm not sure where to do that.

I'm still pretty new to Typescript. With previous modules, I've relied on using @types, and I haven't found concrete documentation on how to set up typings when there is @types aren't present.

https://github.com/vpulim/node-soap/blob/7d912aad2102aced9751e81e76f4a98a930bd0b9/lib/soap.d.ts

Can anyone point me in the right direction?

1

1 Answers

0
votes

Are you sure you are using the right module? The module that has the declaration file soap.d.ts should be installed with:

npm install soap

Then at least for me the following is working, i.e., IntelliSense is displaying the expected parameter types for createClient:

 import * as soap from 'soap';

 var url = 'http://example.com/wsdl?wsdl';
 var args = {name: 'value'};
 soap.createClient(url, function(err, client) { });

The module resolution is explained here.

For module soap, package.json defines "types": "./lib/soap.d.ts".