#Type 'MyProvider' is not assignable to type 'ISmsProvider'

1 messages · Page 1 of 1 (latest)

quaint osprey
#

This might be a little winded but go with me here lol

I'm creating a new SMS provider to allow an enterprise SNPP connection. (more on that in the PR) - anyways, when creating the customSnpp.handler.ts file, and assigning this.provider = new CustomSnppSmsProvider(config); I'm getting an error that states Type 'CustomSnppSmsProvider' is not assignable to type 'ISmsProvider', however everything is set up properly. If I do this.provider = new CustomSnppSmsProvider(config) as any;, the project compiles and runs but I don't like do the any claim in typescript.

Here is a snipping of the Provider:

export class CustomSnppSmsProvider implements ISmsProvider {
  id = 'customsnpp';
  channelType = ChannelTypeEnum.SMS as ChannelTypeEnum.SMS;

  constructor(
    private config: {
      host: string;
      port: number;
      username: string;
      password: string;
    }
  ) {
    this.config = config;
  }

  async sendMessage(
    options: ISmsOptions
  ): Promise<ISendMessageSuccessResponse> {
    const client = new net.Socket();
    let responseCode = '';

......

and here is a snipping of the handler:

export class CustomSnppHandler extends BaseSmsHandler {
  constructor() {
    super('customsnpp', ChannelTypeEnum.SMS);
  }

  buildProvider(credentials: ICredentials) {
    const config: {
      host: string;
      port: number;
      username: string;
      password: string;
    } = {
      host: credentials.host,
      port: +credentials.port,
      username: credentials.user,
      password: credentials.password,
    };

    this.provider = new CustomSnppSmsProvider(config);
  }
}

thoughts?

warm robin
#

<@&986960430528331776> <@&949961460384157746> Please have a look

icy viper
#

Could you send the import part of the handler file?

quaint osprey
#

yessir, one sec

icy viper
#

and for the customSnpp.handler file as well

quaint osprey
vast sundialBOT
#

@quaint osprey, you just advanced to level 4!

spark lion
#

@quaint osprey have you tried to restart TS server, because the code looks ok to me 🙂

vast sundialBOT
#

@spark lion, you just advanced to level 8!

quaint osprey
#

let me try that

#

nope that didn't work 😦

#

this is the full stack trace that it's dumping, for some reason it's not liking the sendMessage function lol

spark lion
#

in the logs I see that the @novu/stateless version that you use is 0.4.1 can you switch to the 0.9.0 ?

quaint osprey
#

woooow i'm dumb lol

#

let me fix that

#

that's the default version that comes from yarn run generate:provider

#

just fyi

spark lion
#

please create a ticket for that 😉

quaint osprey
icy viper
#

For anyone interested, change the version of <@&986249240693080067>/stateless inside this file 😉
_templates/provider/new/package.ejs.t

quaint osprey
#

let me build this out and i can pop in a PR for that if you guys are busy

icy viper
quaint osprey
#

side note: updating that fixed my issues lol

spark lion
#

let's close this one then 😉

quaint osprey
#

so i just noticed, that when I make this PR my local branch is going to push up the outlook365 provider which i have a open PR that's ready for merging ( i think ) anyway we can get that merged before I make this PR so it doesn't do crazy git things? lol

icy viper
#

you can commit your changes for outlook365 in your outlook branch,
then switch to the next branch and pull the latest changes and create a new branch to address this issue

#

and then later go back to outlook branch to continue working on it

quaint osprey
#

sooo that's where I messed up at first, I did that in my local next branch 😬 granted in the future I'm doing things like you stated lol (apologies for being difficult)

quaint osprey