sendinblue/APIv3-typescript-library

Importing Types : Namespace '"http"' has no exported member 'ClientResponse'

Closed this issue · 4 comments

Hi,
I'm having issues importing types from the typescript API.
I wanted to type my SMTPApi client.
I'm having many errors during build :

node_modules/sib-api-v3-typescript/api.d.ts:3059:24 - error TS2694: Namespace '"http"' has no exported member 'ClientResponse'.

Node Version : 12.4.1

The error occurs with the following code. I'm trying to implement the getting started on sending a basic transactional mail.

const SibApiV3Sdk = require('sib-api-v3-typescript');
import { SMTPApi } from 'sib-api-v3-typescript';
import {
  IMailServiceConfiguration,
  IMailServiceSendMailParams,
} from './types';
import { defaultConfiguration } from './config';

/**
 * @description Mail Service
 */
class MailService {
  private readonly config: IMailServiceConfiguration;
  public mailSMTPClient: SMTPApi;

  /**
   * @constructor
   * @param {IMailServiceConfiguration} config
   */
  constructor(config: IMailServiceConfiguration) {
    this.config = { ...defaultConfiguration, ...config };

    let defaultClient = new SibApiV3Sdk.SMTPApi();

    let apiKey = defaultClient.authentications['apiKey'];
    apiKey.apiKey = 'MY_API_KEY';

    this.mailSMTPClient = defaultClient;
  }

  /**
   * @description Sends mail
   * @param {IMailServiceSendMailParams} params
   * @returns {Promise<void>}
   */
  async sendMail(params: IMailServiceSendMailParams): Promise<void> {
    try {
      let sendSmtpEmail = new SibApiV3Sdk.SendSmtpEmail();
      sendSmtpEmail = {
        sender: {
          name: params.fromName,
          email: params.fromEmail,
        },
        to: [
          {
            email: params.contactEmail,
            name: params.contactName,
          },
        ],
        subject: 'Subject',
        textContent: 'Body',
      };
      await this.mailSMTPClient.sendTransacEmail(sendSmtpEmail);
    } catch (error) {
      console.log(error);
      throw error;
    }
  }
}

As soon as i remove the import {SMTPApi} from "sib-api-v3-typescript"; and type my client as any it passes the build. Also tried to import directly from "sib-api-v3-typescript/api.js" but still get the errors.

Any insight ?

Thanks

Same issue here. I can't compile my project. Using Node LTS 12.16.0.

I switched to using basic HTTPS calls using Axios and typing what i needed.

Hi @Theo-Le-Donne
Did you try importing TransactionalEmailsApi from sib-api-v3-typescript?

Hi

The issue is already resolved in the latest release. Thanks for reporting it.