docusign / docusign-esign-node-client

The Official DocuSign Node.js Client Library used to interact with the eSign REST API. Send, sign, and approve documents using this client.
http://docusign.github.io/docusign-esign-node-client
MIT License
146 stars 100 forks source link

Question. Typescript integration. #309

Closed nlapshin closed 1 year ago

nlapshin commented 2 years ago

I try to implement integration using typescript.

I installed "docusign-esign": "5.18.0" and "@types/docusign-esign": "5.6.2". I tried to use some feature and I was seeing some errors in import. For example, Property 'EnvelopeDefinition' does not exist on type 'typeof import("/home/nik/projects/my-project/node_modules/@types/docusign-esign/index")

Maybe, I do something in wrong way.

kollDocuSign commented 2 years ago

@nlapshin Could you provide a bit more background on the exact steps you take to reproduce this error along with at what point exactly does this error occur at? If you have any images you could provide seeing it visually might help as well.

nlapshin commented 2 years ago

Sorry for late answer.

For example, i installed docusign-esign and @types/docusign-esign package and tried to do something like code below:

import { EnvelopeDefinition } from 'docusign-esign';

const env = EnvelopeDefinition();

And I see error 'EnvelopeDefinition' only refers to a type, but is being used as a value here.ts

Because in @types/docusign-esign EnvelopeDefinition is inteface(not class)

kollDocuSign commented 2 years ago

@nlapshin It might be worthwhile to start by using the quick start guide to see working examples and building from the quick start.

The Quick start guide is found here: https://developers.docusign.com/docs/esign-rest-api/quickstart/overview/ We also have a tool you can use where you select a language and use a drag and drop approach to building out sample code here: https://apirequestbuilder.docusign.com/

Both give working examples of creating envelopes via the API that should avoid the types of errors you are running into.

nlapshin commented 2 years ago

@kollDocuSign Thanks for your answer. Unfortunately, there is no example typescript in the examples. I don't have problem usign pure Node.js, I have problems when I use Typescript(and declaration file from @types/docusign-esign).

I found similar problem in stackoverflow https://stackoverflow.com/questions/69429795/unable-to-find-docusign-models-in-typescript-code

nlapshin commented 2 years ago

@kollDocuSign Also, I created simple repo where you can see problems with import some parts of docusign library(Document for example).

https://github.com/nlapshin/docusign-typescript-example/blob/main/src/index.ts

kollDocuSign commented 2 years ago

@nlapshin After some internal outreach the input back was that the SDK doesn't define any types so typescript won’t be supported. A workaround might be to follow this article: https://medium.com/@steveruiz/using-a-javascript-library-without-type-declarations-in-a-typescript-project-3643490015f3