next.js - How to resolve the TypeScript error "Property 'EnvelopeDefinition' does not exist on type &am

admin2025-04-26  7

I am using the DocuSign eSignature SDK in my TypeScript project, and I am encountering the following TypeScript errors when trying to access certain properties:

Property 'EnvelopeDefinition' does not exist on type 'typeof import("c:/Users/USER/Desktop/docusign/node_modules/@types/docusign-esign/index")'.ts(2339) Property 'Tabs' does not exist on type 'typeof import("c:/Users/USER/Desktop/docusign/node_modules/@types/docusign-esign/index")'.ts(2339) Here is the TypeScript function where these errors occur:

function makeEnvelope(name: string, email: string, company: string): docusign.EnvelopeDefinition {
  const env = new docusign.EnvelopeDefinition(); // Error here
  env.templateId = process.env.TEMPLATE_ID!;

  const text = new docusign.Text();
  text.tabLabel = "company_name";
  text.value = company;

  const tabs = new docusign.Tabs(); // Error here
  tabs.textTabs = [text];

  const signer1 = new docusign.TemplateRole();
  signer1.email = email;
  signer1.name = name;
  signer1.tabs = tabs;
  signer1.clientUserId = process.env.CLIENT_USER_ID!;
  signer1.roleName = 'Applicant';

  env.templateRoles = [signer1];
  env.status = "sent";
  return env;
}

Steps I have tried: Ensured that the DocuSign eSignature SDK is installed correctly with npm install docusign-esign. Checked that the @types/docusign-esign package is installed and up-to-date. Verified the proper import of the docusign module: import * as docusign from 'docusign-esign';

What is causing this error, and how can I resolve it to properly access the EnvelopeDefinition and Tabs classes in my TypeScript project?

I am using the DocuSign eSignature SDK in my TypeScript project, and I am encountering the following TypeScript errors when trying to access certain properties:

Property 'EnvelopeDefinition' does not exist on type 'typeof import("c:/Users/USER/Desktop/docusign/node_modules/@types/docusign-esign/index")'.ts(2339) Property 'Tabs' does not exist on type 'typeof import("c:/Users/USER/Desktop/docusign/node_modules/@types/docusign-esign/index")'.ts(2339) Here is the TypeScript function where these errors occur:

function makeEnvelope(name: string, email: string, company: string): docusign.EnvelopeDefinition {
  const env = new docusign.EnvelopeDefinition(); // Error here
  env.templateId = process.env.TEMPLATE_ID!;

  const text = new docusign.Text();
  text.tabLabel = "company_name";
  text.value = company;

  const tabs = new docusign.Tabs(); // Error here
  tabs.textTabs = [text];

  const signer1 = new docusign.TemplateRole();
  signer1.email = email;
  signer1.name = name;
  signer1.tabs = tabs;
  signer1.clientUserId = process.env.CLIENT_USER_ID!;
  signer1.roleName = 'Applicant';

  env.templateRoles = [signer1];
  env.status = "sent";
  return env;
}

Steps I have tried: Ensured that the DocuSign eSignature SDK is installed correctly with npm install docusign-esign. Checked that the @types/docusign-esign package is installed and up-to-date. Verified the proper import of the docusign module: import * as docusign from 'docusign-esign';

What is causing this error, and how can I resolve it to properly access the EnvelopeDefinition and Tabs classes in my TypeScript project?

Share Improve this question asked Jan 15 at 2:58 SMTP KingSMTP King 5281 gold badge6 silver badges15 bronze badges 2
  • Do you have this line at the top: const docusign = require('docusign-esign'); – Inbar Gazit Commented Jan 15 at 3:03
  • Not sure import * as docusign from 'docusign-esign'; works, try to replace it with the require statement and see if that helps – Inbar Gazit Commented Jan 15 at 3:05
Add a comment  | 

1 Answer 1

Reset to default 0

I use "@types/docusign-esign" and would have

import { ApiClient, EnvelopeDefinition } from 'docusign-esign' //include everything you need

Try replacing

const env = new docusign.EnvelopeDefinition(); // Error here

with

const env = <EnvelopeDefinition>{};
转载请注明原文地址:http://anycun.com/QandA/1745601497a91031.html